source: titan/titan/httpdfunc.h @ 32080

Last change on this file since 32080 was 32080, checked in by Stephan, 8 years ago

revert 32078: does not work

File size: 198.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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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        if(fmt == 0)
3401        {
3402                buf = ostrcat(buf, "</body></html>", 1, 0);
3403        }       
3404       
3405        return buf;
3406}
3407
3408char* webgetchannellock(char* param, int fmt)
3409{
3410        char* buf = NULL, *param1 = NULL;
3411        struct channel* chnode = NULL;
3412
3413        if(param == NULL) return NULL;
3414
3415        //create param1
3416        param1 = strchr(param, '&');
3417        if(param1 != NULL)
3418                *param1++ = '\0';
3419
3420        if(param1 == NULL) return NULL;
3421
3422        chnode = getchannel(atoi(param), strtoull(param1, NULL, 10));
3423        if(chnode != NULL)
3424        {
3425                buf = ostrcat(buf, chnode->name, 1, 0);
3426                buf = ostrcat(buf, "#", 1, 0);
3427                buf = ostrcat(buf, oitoa(chnode->serviceid), 1, 1);
3428                buf = ostrcat(buf, "#", 1, 0);
3429                buf = ostrcat(buf, ollutoa(chnode->transponderid), 1, 1);
3430                buf = ostrcat(buf, "#", 1, 0);
3431
3432                if(channelnottunable(chnode) == 1)
3433                        buf = ostrcat(buf, "1", 1, 0);
3434                else
3435                        buf = ostrcat(buf, "0", 1, 0);
3436        }
3437        else
3438                buf = ostrcat("no data", NULL, 0, 0);
3439
3440        return buf;
3441}
3442
3443char* webgetbouquetepg(char* param, int fmt)
3444{
3445        char* buf = NULL, *tmpstr = NULL, *tmpstr1 = NULL;
3446        char* param1 = NULL, *param2 = NULL, *param3 = NULL;
3447        struct mainbouquet *mbouquet = NULL;
3448        struct bouquet *node = NULL;
3449        struct channel* chnode = NULL;
3450        struct epg* epgnode = NULL;
3451        int longepg = 0;
3452        time_t start = 0, end = 0;
3453
3454        if(param == NULL) return NULL;
3455
3456        //create param1 + 2 + 3
3457        param1 = strchr(param, '&');
3458        if(param1 != NULL)
3459        {
3460                *param1++ = '\0';
3461                param2 = strchr(param1, '&');
3462                if(param2 != NULL)
3463                {
3464                        *param2++ = '\0';
3465                        param3 = strchr(param2, '&');
3466                        if(param3 != NULL)
3467                                *param3++ = '\0';
3468                }
3469        }
3470        if(param1 == NULL || param2 == NULL || param3 == NULL) return NULL;
3471
3472        longepg = atoi(param1);
3473        start = atoi(param2);
3474        end = atoi(param3);
3475
3476        mbouquet = getmainbouquet(param);
3477        if(mbouquet != NULL)
3478        {
3479                node = mbouquet->bouquet;
3480                tmpstr = ostrcat(tmpstr, "(BOUQUET)-", 1, 0);
3481                tmpstr = ostrcat(tmpstr, mbouquet->name, 1, 0);
3482                tmpstr1 = htmlencode(tmpstr);
3483                free(tmpstr); tmpstr = NULL;
3484                while(node != NULL)
3485                {
3486                        chnode = getchannel(node->serviceid, node->transponderid);
3487                        if(chnode != NULL)
3488                        {
3489                                buf = ostrcat(buf, "BeginNewChannel", 1, 0);
3490                                buf = ostrcat(buf, "#", 1, 0);
3491                                buf = ostrcat(buf, chnode->name, 1, 0);
3492                                buf = ostrcat(buf, "#", 1, 0);
3493                                buf = ostrcat(buf, oitoa(chnode->serviceid), 1, 1);
3494                                buf = ostrcat(buf, "#", 1, 0);
3495                                buf = ostrcat(buf, ollutoa(chnode->transponderid), 1, 1);
3496                                buf = ostrcat(buf, "#", 1, 0);
3497                                buf = ostrcat(buf, oitoa(chnode->servicetype), 1, 1);
3498                                buf = ostrcat(buf, "\n", 1, 0);
3499
3500                                epgnode = chnode->epg;
3501                                while(epgnode != NULL)
3502                                {
3503                                        if((epgnode->starttime >= start && epgnode->starttime < end) || (epgnode->endtime > start && epgnode->endtime <= end) || (epgnode->starttime < start && epgnode->endtime > end))
3504                                        {
3505                                                buf = ostrcat(buf, epgnode->title, 1, 0);
3506                                                buf = ostrcat(buf, "#", 1, 0);
3507                                                buf = ostrcat(buf, olutoa(epgnode->starttime), 1, 1);
3508                                                buf = ostrcat(buf, "#", 1, 0);
3509                                                buf = ostrcat(buf, olutoa(epgnode->endtime), 1, 1);
3510                                                buf = ostrcat(buf, "#", 1, 0);
3511                                                buf = ostrcat(buf, epgnode->subtitle, 1, 0);
3512                                                buf = ostrcat(buf, "#", 1, 0);
3513
3514                                                if(longepg == 1)
3515                                                {
3516                                                        tmpstr = epgdescunzip(epgnode);
3517                                                        if(tmpstr != NULL)
3518                                                                buf = ostrcat(buf, tmpstr, 1, 0);
3519                                                        free(tmpstr); tmpstr = NULL;
3520                                                }
3521
3522                                                buf = ostrcat(buf, "#", 1, 0);
3523                                                buf = ostrcat(buf, oitoa(epgnode->eventid), 1, 1);
3524                                                buf = ostrcat(buf, "\n", 1, 0);
3525                                        }
3526
3527                                        epgnode = epgnode->next;
3528                                }
3529                        }
3530                        node = node->next;
3531                }
3532                free(tmpstr1); tmpstr1 = NULL;
3533        }
3534
3535        if(buf == NULL)
3536                buf = ostrcat("no data", NULL, 0, 0);
3537        return buf;
3538}
3539
3540char* webadjust(char* param, int fmt)
3541{
3542printf("webadjust param: %s\n",param);
3543printf("webadjust fmt: %d\n",fmt);
3544
3545        char* buf = NULL, *tmpstr = NULL, *tmpstr1 = NULL, *tmpstr2 = NULL, *sendstr = NULL;
3546        int i = 0, max = 0, count = 0, maxlen = 0, pos = 0;
3547
3548       
3549        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);
3550        ostrcatbig(&buf, "<body class=body ><center>", &maxlen, &pos);
3551        ostrcatbig(&buf, "<form name=F1 action=query method=get><br><br>", &maxlen, &pos);
3552        ostrcatbig(&buf, "<input type=\"hidden\" name=\"adjustsend&node\" value=\"", &maxlen, &pos);
3553        ostrcatbig(&buf, "0", &maxlen, &pos);
3554        ostrcatbig(&buf, "\">", &maxlen, &pos);
3555//      ostrcatbig(&buf, "<input type=\"hidden\" name=\"adjustsend\">", &maxlen, &pos);
3556        ostrcatbig(&buf, "<table border=\"0\"><tr>", &maxlen, &pos);
3557
3558        ostrcatbig(&buf, "<table>", &maxlen, &pos);
3559
3560///////////////////
3561//      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);
3562        max = 10;
3563        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
3564        ostrcatbig(&buf, _("Volumebar Timeout"), &maxlen, &pos);
3565        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"volbartimeout\" border=\"0\">", &maxlen, &pos);
3566        for(i = 1; i <= max; i++)
3567        {
3568                ostrcatbig(&buf, "<option value=\"", &maxlen, &pos);
3569                ostrcatbig(&buf, oitoa(i), &maxlen, &pos);             
3570                if(getconfigint("volbartimeout", NULL) == i)
3571                        ostrcatbig(&buf, "\" selected>", &maxlen, &pos);               
3572                else
3573                        ostrcatbig(&buf, "\">", &maxlen, &pos);
3574                ostrcatbig(&buf, oitoa(i), &maxlen, &pos);
3575                ostrcatbig(&buf, "</option>", &maxlen, &pos);
3576        }
3577        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
3578        sendstr = ostrcat(sendstr, "volbartimeout.value", 1 , 0);
3579
3580///////////////////
3581//      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);
3582        max = 10;
3583        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
3584        ostrcatbig(&buf, _("Infobar Timeout"), &maxlen, &pos);
3585        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"infobartimeout\" border=\"0\">", &maxlen, &pos);
3586        for(i = 1; i <= max; i++)
3587        {
3588                ostrcatbig(&buf, "<option value=\"", &maxlen, &pos);
3589                ostrcatbig(&buf, oitoa(i), &maxlen, &pos);     
3590                if(getconfigint("infobartimeout", NULL) == i)
3591                        ostrcatbig(&buf, "\" selected>", &maxlen, &pos);               
3592                else
3593                        ostrcatbig(&buf, "\">", &maxlen, &pos);
3594                ostrcatbig(&buf, oitoa(i), &maxlen, &pos);
3595                ostrcatbig(&buf, "</option>", &maxlen, &pos);
3596        }
3597        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
3598        sendstr = ostrcat(sendstr, ", infobartimeout.value", 1 , 0);
3599
3600///////////////////
3601//      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);
3602        max = 5;
3603        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
3604        ostrcatbig(&buf, _("Infobar Sleep"), &maxlen, &pos);
3605        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"infobarsleep\" border=\"0\">", &maxlen, &pos);
3606        for(i = 0; i <= max; i++)
3607        {
3608                ostrcatbig(&buf, "<option value=\"", &maxlen, &pos);
3609                ostrcatbig(&buf, oitoa(i), &maxlen, &pos);             
3610                if(getconfigint("infobarsleep", NULL) == i)
3611                        ostrcatbig(&buf, "\" selected>", &maxlen, &pos);               
3612                else
3613                        ostrcatbig(&buf, "\">", &maxlen, &pos);
3614                ostrcatbig(&buf, oitoa(i), &maxlen, &pos);
3615                ostrcatbig(&buf, "</option>", &maxlen, &pos);
3616        }
3617        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
3618        sendstr = ostrcat(sendstr, ", infobarsleep.value", 1 , 0);
3619
3620///////////////////
3621//      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);
3622        max = 5;
3623        tmpstr = ostrcat("1\n3\n9\n12\n15\n18\n21\n24\n27\n30", NULL, 0, 0);
3624
3625        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
3626        ostrcatbig(&buf, _("Spinnerspeed"), &maxlen, &pos);
3627        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"spinnerspeed\" border=\"0\">", &maxlen, &pos);
3628
3629        count = 0;
3630        struct splitstr* ret1 = NULL;
3631        ret1 = strsplit(tmpstr, "\n", &count);
3632        max = count - 1;
3633
3634        if(ret1 != NULL)
3635        {
3636                for(i = 0; i <= max; i++)
3637                {
3638                        ostrcatbig(&buf, "<option value=\"", &maxlen, &pos);
3639                        ostrcatbig(&buf, ret1[i].part, &maxlen, &pos);
3640                        tmpstr1 = ostrcat(ret1[i].part, NULL, 0, 0);
3641                        if(getconfigint("spinnerspeed", NULL) == atoi(tmpstr1))
3642                                ostrcatbig(&buf, "\" selected>", &maxlen, &pos);               
3643                        else
3644                                ostrcatbig(&buf, "\">", &maxlen, &pos);
3645                        ostrcatbig(&buf, ret1[i].part, &maxlen, &pos);
3646                        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3647                }
3648        }
3649        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
3650        sendstr = ostrcat(sendstr, ", spinnerspeed.value", 1 , 0);
3651        free(ret1), ret1 = NULL;
3652        free(tmpstr), tmpstr = NULL;
3653        free(tmpstr1), tmpstr1 = NULL;
3654
3655///////////////////
3656        tmpstr = ostrcat("1\n2\n3\n4\n5\n6\n7\n8\n10000", NULL, 0, 0);
3657
3658        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
3659        ostrcatbig(&buf, _("Spinnertime"), &maxlen, &pos);
3660        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"spinnertime\" border=\"0\">", &maxlen, &pos);
3661
3662        count = 0;
3663        ret1 = strsplit(tmpstr, "\n", &count);
3664        max = count - 1;
3665
3666        if(ret1 != NULL)
3667        {
3668                for(i = 0; i <= max; i++)
3669                {
3670                        ostrcatbig(&buf, "<option value=\"", &maxlen, &pos);
3671                        ostrcatbig(&buf, ret1[i].part, &maxlen, &pos);
3672                        tmpstr1 = ostrcat(ret1[i].part, NULL, 0, 0);
3673                        if(getconfigint("spinnertime", NULL) == atoi(tmpstr1)) 
3674                                ostrcatbig(&buf, "\" selected>", &maxlen, &pos);               
3675                        else
3676                                ostrcatbig(&buf, "\">", &maxlen, &pos);
3677                        ostrcatbig(&buf, ret1[i].part, &maxlen, &pos);
3678                        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3679                }
3680        }
3681        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
3682        sendstr = ostrcat(sendstr, ", spinnertime.value", 1 , 0);
3683        free(ret1), ret1 = NULL;
3684        free(tmpstr), tmpstr = NULL;
3685        free(tmpstr1), tmpstr1 = NULL;
3686
3687///////////////////
3688        tmpstr = ostrcat("5\n10\n15\n30\n60\n120\n10000", NULL, 0, 0);
3689
3690        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
3691        ostrcatbig(&buf, _("Hangtime"), &maxlen, &pos);
3692        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"hangtime\" border=\"0\">", &maxlen, &pos);
3693
3694        count = 0;
3695        ret1 = strsplit(tmpstr, "\n", &count);
3696        max = count - 1;
3697
3698        if(ret1 != NULL)
3699        {
3700                for(i = 0; i <= max; i++)
3701                {
3702                        ostrcatbig(&buf, "<option value=\"", &maxlen, &pos);
3703                        ostrcatbig(&buf, ret1[i].part, &maxlen, &pos);         
3704                        tmpstr1 = ostrcat(ret1[i].part, NULL, 0, 0);
3705                        if(getconfigint("hangtime", NULL) == atoi(tmpstr1))
3706                                ostrcatbig(&buf, "\" selected>", &maxlen, &pos);               
3707                        else
3708                                ostrcatbig(&buf, "\">", &maxlen, &pos);
3709                        ostrcatbig(&buf, ret1[i].part, &maxlen, &pos);
3710                        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3711                }
3712        }
3713        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
3714        sendstr = ostrcat(sendstr, ", hangtime.value", 1 , 0);
3715        free(ret1), ret1 = NULL;
3716        free(tmpstr), tmpstr = NULL;
3717        free(tmpstr1), tmpstr1 = NULL;
3718
3719///////////////////
3720//      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);
3721        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
3722        ostrcatbig(&buf, _("Second Infobar"), &maxlen, &pos);
3723        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"secondinfobar\" border=\"0\">", &maxlen, &pos);
3724       
3725        if(getconfigint("secondinfobar", NULL) == 0)
3726                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
3727        else
3728                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
3729        ostrcatbig(&buf, _("no"), &maxlen, &pos);
3730        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3731
3732        if(getconfigint("secondinfobar", NULL) == 1)
3733                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
3734        else
3735                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
3736        ostrcatbig(&buf, _("infobar"), &maxlen, &pos);
3737        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3738
3739        if(getconfigint("secondinfobar", NULL) == 2)
3740                ostrcatbig(&buf, "<option value=\"2\" selected>", &maxlen, &pos);               
3741        else
3742                ostrcatbig(&buf, "<option value=\"2\">", &maxlen, &pos);
3743        ostrcatbig(&buf, _("epg"), &maxlen, &pos);
3744        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3745
3746        if(getconfigint("secondinfobar", NULL) == 3)
3747                ostrcatbig(&buf, "<option value=\"3\" selected>", &maxlen, &pos);               
3748        else
3749                ostrcatbig(&buf, "<option value=\"3\">", &maxlen, &pos);
3750        ostrcatbig(&buf, _("Channel EPG"), &maxlen, &pos);
3751        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3752       
3753        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
3754        sendstr = ostrcat(sendstr, ", secondinfobar.value", 1 , 0);
3755
3756///////////////////
3757        if(checkbox("ATEMIO7600") != 1)
3758        {
3759                ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
3760                ostrcatbig(&buf, _("Don't clear TV on zap (only with fastzap)"), &maxlen, &pos);
3761                ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"nozapclear\" border=\"0\">", &maxlen, &pos);
3762       
3763                if(getconfigint("nozapclear", NULL) == 0)
3764                        ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
3765                else
3766                        ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
3767                ostrcatbig(&buf, _("no"), &maxlen, &pos);
3768                ostrcatbig(&buf, "</option>", &maxlen, &pos);
3769
3770                if(getconfigint("nozapclear", NULL) == 1)
3771                        ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
3772                else
3773                        ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
3774                ostrcatbig(&buf, _("yes"), &maxlen, &pos);
3775                ostrcatbig(&buf, "</option>", &maxlen, &pos);
3776       
3777                ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
3778                sendstr = ostrcat(sendstr, ", nozapclear.value", 1 , 0);
3779        }
3780
3781///////////////////
3782        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
3783        ostrcatbig(&buf, _("Fastzap"), &maxlen, &pos);
3784        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"fastzap\" border=\"0\">", &maxlen, &pos);
3785       
3786        if(getconfigint("fastzap", NULL) == 0)
3787                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
3788        else
3789                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
3790        ostrcatbig(&buf, _("no"), &maxlen, &pos);
3791        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3792
3793        if(getconfigint("fastzap", NULL) == 1)
3794                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
3795        else
3796                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
3797        ostrcatbig(&buf, _("medium"), &maxlen, &pos);
3798        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3799
3800        if(getconfigint("fastzap", NULL) == 2)
3801                ostrcatbig(&buf, "<option value=\"2\" selected>", &maxlen, &pos);               
3802        else
3803                ostrcatbig(&buf, "<option value=\"2\">", &maxlen, &pos);
3804        ostrcatbig(&buf, _("fast"), &maxlen, &pos);
3805        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3806       
3807        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
3808        sendstr = ostrcat(sendstr, ", fastzap.value", 1 , 0);
3809
3810///////////////////
3811        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
3812        ostrcatbig(&buf, _("Faststop"), &maxlen, &pos);
3813        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"faststop\" border=\"0\">", &maxlen, &pos);
3814       
3815        if(getconfigint("faststop", NULL) == 0)
3816                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
3817        else
3818                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
3819        ostrcatbig(&buf, _("no"), &maxlen, &pos);
3820        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3821
3822        if(getconfigint("faststop", NULL) == 1)
3823                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
3824        else
3825                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
3826        ostrcatbig(&buf, _("yes"), &maxlen, &pos);
3827        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3828       
3829        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
3830        sendstr = ostrcat(sendstr, ", faststop.value", 1 , 0);
3831
3832///////////////////
3833        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
3834        ostrcatbig(&buf, _("Dirsort"), &maxlen, &pos);
3835        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"dirsort\" border=\"0\">", &maxlen, &pos);
3836       
3837        if(getconfigint("dirsort", NULL) == 0)
3838                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
3839        else
3840                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
3841        ostrcatbig(&buf, _("alpha"), &maxlen, &pos);
3842        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3843
3844        if(getconfigint("dirsort", NULL) == 1)
3845                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
3846        else
3847                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
3848        ostrcatbig(&buf, _("reverse alpha"), &maxlen, &pos);
3849        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3850
3851        if(getconfigint("dirsort", NULL) == 2)
3852                ostrcatbig(&buf, "<option value=\"2\" selected>", &maxlen, &pos);               
3853        else
3854                ostrcatbig(&buf, "<option value=\"2\">", &maxlen, &pos);
3855        ostrcatbig(&buf, _("size"), &maxlen, &pos);
3856        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3857
3858        if(getconfigint("dirsort", NULL) == 3)
3859                ostrcatbig(&buf, "<option value=\"3\" selected>", &maxlen, &pos);               
3860        else
3861                ostrcatbig(&buf, "<option value=\"3\">", &maxlen, &pos);
3862        ostrcatbig(&buf, _("reverse size"), &maxlen, &pos);
3863        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3864
3865        if(getconfigint("dirsort", NULL) == 4)
3866                ostrcatbig(&buf, "<option value=\"4\" selected>", &maxlen, &pos);               
3867        else
3868                ostrcatbig(&buf, "<option value=\"4\">", &maxlen, &pos);
3869        ostrcatbig(&buf, _("date"), &maxlen, &pos);
3870        ostrcatbig(&buf, "</option>", &maxlen, &pos);   
3871
3872        if(getconfigint("dirsort", NULL) == 5)
3873                ostrcatbig(&buf, "<option value=\"5\" selected>", &maxlen, &pos);               
3874        else
3875                ostrcatbig(&buf, "<option value=\"5\">", &maxlen, &pos);
3876        ostrcatbig(&buf, _("reverse date"), &maxlen, &pos);
3877        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3878       
3879        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
3880        sendstr = ostrcat(sendstr, ", dirsort.value", 1 , 0);
3881
3882///////////////////rcpower
3883        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
3884        ostrcatbig(&buf, _("Remotecontrol Power Aktion"), &maxlen, &pos);
3885        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"poweraktion\" border=\"0\">", &maxlen, &pos);
3886       
3887        if(getconfigint("poweraktion", NULL) == 0)
3888                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
3889        else
3890                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
3891        ostrcatbig(&buf, _("Power Menu"), &maxlen, &pos);
3892        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3893
3894        if(getconfigint("poweraktion", NULL) == 1)
3895                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
3896        else
3897                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
3898        ostrcatbig(&buf, _("Power Off"), &maxlen, &pos);
3899        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3900
3901        if(getconfigint("poweraktion", NULL) == 2)
3902                ostrcatbig(&buf, "<option value=\"2\" selected>", &maxlen, &pos);               
3903        else
3904                ostrcatbig(&buf, "<option value=\"2\">", &maxlen, &pos);
3905        ostrcatbig(&buf, _("Standby"), &maxlen, &pos);
3906        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3907
3908        if(getconfigint("poweraktion", NULL) == 3)
3909                ostrcatbig(&buf, "<option value=\"3\" selected>", &maxlen, &pos);               
3910        else
3911                ostrcatbig(&buf, "<option value=\"3\">", &maxlen, &pos);
3912        ostrcatbig(&buf, _("Restart"), &maxlen, &pos);
3913        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3914
3915        if(getconfigint("poweraktion", NULL) == 4)
3916                ostrcatbig(&buf, "<option value=\"4\" selected>", &maxlen, &pos);               
3917        else
3918                ostrcatbig(&buf, "<option value=\"4\">", &maxlen, &pos);
3919        ostrcatbig(&buf, _("Gui Restart"), &maxlen, &pos);
3920        ostrcatbig(&buf, "</option>", &maxlen, &pos);   
3921       
3922        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
3923        sendstr = ostrcat(sendstr, ", poweraktion.value", 1 , 0);
3924
3925///////////////////frontpower
3926        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
3927        ostrcatbig(&buf, _("Frontpanel Power Aktion"), &maxlen, &pos);
3928        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"frontpoweraktion\" border=\"0\">", &maxlen, &pos);
3929       
3930        if(getconfigint("frontpoweraktion", NULL) == 1)
3931                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
3932        else
3933                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
3934        ostrcatbig(&buf, _("Power Off"), &maxlen, &pos);
3935        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3936
3937        if(getconfigint("frontpoweraktion", NULL) == 2)
3938                ostrcatbig(&buf, "<option value=\"2\" selected>", &maxlen, &pos);               
3939        else
3940                ostrcatbig(&buf, "<option value=\"2\">", &maxlen, &pos);
3941        ostrcatbig(&buf, _("Standby"), &maxlen, &pos);
3942        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3943
3944        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
3945        sendstr = ostrcat(sendstr, ", frontpoweraktion.value", 1 , 0);
3946
3947///////////////////
3948        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
3949        ostrcatbig(&buf, _("Virtualzap Timeout"), &maxlen, &pos);
3950        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"virtualzap\" border=\"0\">", &maxlen, &pos);
3951       
3952        if(getconfigint("virtualzap", NULL) == 0)
3953                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
3954        else
3955                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
3956        ostrcatbig(&buf, _("deaktiv"), &maxlen, &pos);
3957        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3958
3959        if(getconfigint("virtualzap", NULL) == 1)
3960                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
3961        else
3962                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
3963        ostrcatbig(&buf, _("1 sec"), &maxlen, &pos);
3964        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3965
3966        if(getconfigint("virtualzap", NULL) == 2)
3967                ostrcatbig(&buf, "<option value=\"2\" selected>", &maxlen, &pos);               
3968        else
3969                ostrcatbig(&buf, "<option value=\"2\">", &maxlen, &pos);
3970        ostrcatbig(&buf, _("2 sec"), &maxlen, &pos);
3971        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3972
3973        if(getconfigint("virtualzap", NULL) == 3)
3974                ostrcatbig(&buf, "<option value=\"3\" selected>", &maxlen, &pos);               
3975        else
3976                ostrcatbig(&buf, "<option value=\"3\">", &maxlen, &pos);
3977        ostrcatbig(&buf, _("endless"), &maxlen, &pos);
3978        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3979       
3980        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
3981        sendstr = ostrcat(sendstr, ", virtualzap.value", 1 , 0);
3982       
3983///////////////////
3984        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
3985        ostrcatbig(&buf, _("Fast Text Render"), &maxlen, &pos);
3986        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"fasttextrender\" border=\"0\">", &maxlen, &pos);
3987       
3988        if(getconfigint("fasttextrender", NULL) == 0)
3989                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
3990        else
3991                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
3992        ostrcatbig(&buf, _("no"), &maxlen, &pos);
3993        ostrcatbig(&buf, "</option>", &maxlen, &pos);
3994
3995        if(getconfigint("fasttextrender", NULL) == 1)
3996                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
3997        else
3998                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
3999        ostrcatbig(&buf, _("yes"), &maxlen, &pos);
4000        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4001       
4002        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4003        sendstr = ostrcat(sendstr, ", fasttextrender.value", 1 , 0);
4004
4005///////////////////
4006        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4007        ostrcatbig(&buf, _("Record Split Size"), &maxlen, &pos);
4008        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"recsplitsize\" border=\"0\">", &maxlen, &pos);
4009       
4010        if(getconfigint("recsplitsize", NULL) == 0)
4011                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
4012        else
4013                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
4014        ostrcatbig(&buf, _("deaktiv"), &maxlen, &pos);
4015        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4016
4017        if(getconfigint("recsplitsize", NULL) == 1)
4018                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
4019        else
4020                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
4021        ostrcatbig(&buf, _("1 GB"), &maxlen, &pos);
4022        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4023
4024        if(getconfigint("recsplitsize", NULL) == 2)
4025                ostrcatbig(&buf, "<option value=\"2\" selected>", &maxlen, &pos);               
4026        else
4027                ostrcatbig(&buf, "<option value=\"2\">", &maxlen, &pos);
4028        ostrcatbig(&buf, _("2 GB"), &maxlen, &pos);
4029        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4030
4031        if(getconfigint("recsplitsize", NULL) == 3)
4032                ostrcatbig(&buf, "<option value=\"3\" selected>", &maxlen, &pos);               
4033        else
4034                ostrcatbig(&buf, "<option value=\"3\">", &maxlen, &pos);
4035        ostrcatbig(&buf, _("3 GB"), &maxlen, &pos);
4036        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4037
4038        if(getconfigint("recsplitsize", NULL) == 4)
4039                ostrcatbig(&buf, "<option value=\"4\" selected>", &maxlen, &pos);               
4040        else
4041                ostrcatbig(&buf, "<option value=\"4\">", &maxlen, &pos);
4042        ostrcatbig(&buf, _("4 GB"), &maxlen, &pos);
4043        ostrcatbig(&buf, "</option>", &maxlen, &pos);   
4044       
4045        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4046        sendstr = ostrcat(sendstr, ", recsplitsize.value", 1 , 0);
4047
4048///////////////////
4049        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);
4050
4051        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4052        ostrcatbig(&buf, _("Record Forerun (min)"), &maxlen, &pos);
4053        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"recforerun\" border=\"0\">", &maxlen, &pos);
4054
4055        count = 0;
4056        ret1 = strsplit(tmpstr, "\n", &count);
4057        max = count - 1;
4058
4059        if(ret1 != NULL)
4060        {
4061                for(i = 0; i <= max; i++)
4062                {
4063                        ostrcatbig(&buf, "<option value=\"", &maxlen, &pos);
4064                        ostrcatbig(&buf, ret1[i].part, &maxlen, &pos);         
4065                        tmpstr1 = ostrcat(ret1[i].part, NULL, 0, 0);
4066                        if(getconfigint("recforerun", NULL) == atoi(tmpstr1))
4067                                ostrcatbig(&buf, "\" selected>", &maxlen, &pos);               
4068                        else
4069                                ostrcatbig(&buf, "\">", &maxlen, &pos);
4070                        ostrcatbig(&buf, ret1[i].part, &maxlen, &pos);
4071                        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4072                }
4073        }
4074        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4075        sendstr = ostrcat(sendstr, ", recforerun.value", 1 , 0);
4076        free(ret1), ret1 = NULL;
4077        free(tmpstr), tmpstr = NULL;
4078        free(tmpstr1), tmpstr1 = NULL;
4079
4080///////////////////
4081        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);
4082
4083        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4084        ostrcatbig(&buf, _("Record Overrun (min)"), &maxlen, &pos);
4085        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"recoverrun\" border=\"0\">", &maxlen, &pos);
4086
4087        count = 0;
4088        ret1 = strsplit(tmpstr, "\n", &count);
4089        max = count - 1;
4090
4091        if(ret1 != NULL)
4092        {
4093                for(i = 0; i <= max; i++)
4094                {
4095                        ostrcatbig(&buf, "<option value=\"", &maxlen, &pos);
4096                        ostrcatbig(&buf, ret1[i].part, &maxlen, &pos);         
4097                        tmpstr1 = ostrcat(ret1[i].part, NULL, 0, 0);
4098                        if(getconfigint("recoverrun", NULL) == atoi(tmpstr1))
4099                                ostrcatbig(&buf, "\" selected>", &maxlen, &pos);               
4100                        else
4101                                ostrcatbig(&buf, "\">", &maxlen, &pos);
4102                        ostrcatbig(&buf, ret1[i].part, &maxlen, &pos);
4103                        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4104                }
4105        }
4106        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4107        sendstr = ostrcat(sendstr, ", recoverrun.value", 1 , 0);
4108        free(ret1), ret1 = NULL;
4109        free(tmpstr), tmpstr = NULL;
4110        free(tmpstr1), tmpstr1 = NULL;
4111
4112///////////////////
4113        tmpstr = ostrcat("15\n20\n30\n45\n60\n90\n120\n180\n300\n600\n900\n1200", NULL, 0, 0);
4114
4115        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4116        ostrcatbig(&buf, _("Skip 1/3"), &maxlen, &pos);
4117        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"skip13\" border=\"0\">", &maxlen, &pos);
4118
4119        count = 0;
4120        ret1 = strsplit(tmpstr, "\n", &count);
4121        max = count - 1;
4122
4123        if(ret1 != NULL)
4124        {
4125                for(i = 0; i <= max; i++)
4126                {
4127                        ostrcatbig(&buf, "<option value=\"", &maxlen, &pos);
4128                        ostrcatbig(&buf, ret1[i].part, &maxlen, &pos);         
4129                        tmpstr1 = ostrcat(ret1[i].part, NULL, 0, 0);
4130                        if(getconfigint("skip13", NULL) == atoi(tmpstr1))
4131                                ostrcatbig(&buf, "\" selected>", &maxlen, &pos);               
4132                        else
4133                                ostrcatbig(&buf, "\">", &maxlen, &pos);
4134                        ostrcatbig(&buf, ret1[i].part, &maxlen, &pos);
4135                        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4136                }
4137        }
4138        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4139        sendstr = ostrcat(sendstr, ", skip13.value", 1 , 0);
4140        free(ret1), ret1 = NULL;
4141        free(tmpstr), tmpstr = NULL;
4142        free(tmpstr1), tmpstr1 = NULL;
4143
4144///////////////////
4145        tmpstr = ostrcat("15\n20\n30\n45\n60\n90\n120\n180\n300\n600\n900\n1200", NULL, 0, 0);
4146
4147        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4148        ostrcatbig(&buf, _("Skip 4/6"), &maxlen, &pos);
4149        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"skip46\" border=\"0\">", &maxlen, &pos);
4150
4151        count = 0;
4152        ret1 = strsplit(tmpstr, "\n", &count);
4153        max = count - 1;
4154
4155        if(ret1 != NULL)
4156        {
4157                for(i = 0; i <= max; i++)
4158                {
4159                        ostrcatbig(&buf, "<option value=\"", &maxlen, &pos);
4160                        ostrcatbig(&buf, ret1[i].part, &maxlen, &pos);         
4161                        tmpstr1 = ostrcat(ret1[i].part, NULL, 0, 0);
4162                        if(getconfigint("skip46", NULL) == atoi(tmpstr1))
4163                                ostrcatbig(&buf, "\" selected>", &maxlen, &pos);               
4164                        else
4165                                ostrcatbig(&buf, "\">", &maxlen, &pos);
4166                        ostrcatbig(&buf, ret1[i].part, &maxlen, &pos);
4167                        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4168                }
4169        }
4170        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4171        sendstr = ostrcat(sendstr, ", skip46.value", 1 , 0);
4172        free(ret1), ret1 = NULL;
4173        free(tmpstr), tmpstr = NULL;
4174        free(tmpstr1), tmpstr1 = NULL;
4175       
4176///////////////////
4177        tmpstr = ostrcat("15\n20\n30\n45\n60\n90\n120\n180\n300\n600\n900\n1200", NULL, 0, 0);
4178
4179        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4180        ostrcatbig(&buf, _("Skip 7/9"), &maxlen, &pos);
4181        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"skip79\" border=\"0\">", &maxlen, &pos);
4182
4183        count = 0;
4184        ret1 = strsplit(tmpstr, "\n", &count);
4185        max = count - 1;
4186
4187        if(ret1 != NULL)
4188        {
4189                for(i = 0; i <= max; i++)
4190                {
4191                        ostrcatbig(&buf, "<option value=\"", &maxlen, &pos);
4192                        ostrcatbig(&buf, ret1[i].part, &maxlen, &pos);         
4193                        tmpstr1 = ostrcat(ret1[i].part, NULL, 0, 0);
4194                        if(getconfigint("skip79", NULL) == atoi(tmpstr1))
4195                                ostrcatbig(&buf, "\" selected>", &maxlen, &pos);               
4196                        else
4197                                ostrcatbig(&buf, "\">", &maxlen, &pos);
4198                        ostrcatbig(&buf, ret1[i].part, &maxlen, &pos);
4199                        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4200                }
4201        }
4202        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4203        sendstr = ostrcat(sendstr, ", skip79.value", 1 , 0);
4204        free(ret1), ret1 = NULL;
4205        free(tmpstr), tmpstr = NULL;
4206        free(tmpstr1), tmpstr1 = NULL;
4207       
4208///////////////////
4209        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4210        ostrcatbig(&buf, _("Player for .ts"), &maxlen, &pos);
4211        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"playertype\" border=\"0\">", &maxlen, &pos);
4212       
4213        if(getconfigint("playertype", NULL) == 0)
4214                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
4215        else
4216                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
4217        ostrcatbig(&buf, _("extern"), &maxlen, &pos);
4218        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4219
4220        if(getconfigint("faststop", NULL) == 1)
4221                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
4222        else
4223                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
4224        ostrcatbig(&buf, _("intern"), &maxlen, &pos);
4225        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4226       
4227        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4228        sendstr = ostrcat(sendstr, ", playertype.value", 1 , 0);
4229
4230///////////////////
4231        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4232        ostrcatbig(&buf, _("Change Channelname auto."), &maxlen, &pos);
4233        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"autochangechannelname\" border=\"0\">", &maxlen, &pos);
4234       
4235        if(getconfigint("autochangechannelname", NULL) == 0)
4236                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
4237        else
4238                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
4239        ostrcatbig(&buf, _("no"), &maxlen, &pos);
4240        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4241
4242        if(getconfigint("autochangechannelname", NULL) == 1)
4243                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
4244        else
4245                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
4246        ostrcatbig(&buf, _("yes"), &maxlen, &pos);
4247        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4248       
4249        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4250        sendstr = ostrcat(sendstr, ", autochangechannelname.value", 1 , 0);
4251
4252///////////////////
4253        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4254        ostrcatbig(&buf, _("Set action after rec"), &maxlen, &pos);
4255        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"def_rectimer_after\" border=\"0\">", &maxlen, &pos);
4256       
4257        if(getconfigint("def_rectimer_after", NULL) == 0)
4258                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
4259        else
4260                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
4261        ostrcatbig(&buf, _("auto"), &maxlen, &pos);
4262        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4263
4264        if(getconfigint("def_rectimer_after", NULL) == 1)
4265                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
4266        else
4267                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
4268        ostrcatbig(&buf, _("nothing"), &maxlen, &pos);
4269        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4270
4271        if(getconfigint("def_rectimer_after", NULL) == 2)
4272                ostrcatbig(&buf, "<option value=\"2\" selected>", &maxlen, &pos);               
4273        else
4274                ostrcatbig(&buf, "<option value=\"2\">", &maxlen, &pos);
4275        ostrcatbig(&buf, _("standby"), &maxlen, &pos);
4276        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4277
4278        if(getconfigint("def_rectimer_after", NULL) == 3)
4279                ostrcatbig(&buf, "<option value=\"3\" selected>", &maxlen, &pos);               
4280        else
4281                ostrcatbig(&buf, "<option value=\"3\">", &maxlen, &pos);
4282        ostrcatbig(&buf, _("power off"), &maxlen, &pos);
4283        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4284       
4285        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4286        sendstr = ostrcat(sendstr, ", def_rectimer_after.value", 1 , 0);
4287
4288///////////////////
4289        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4290        ostrcatbig(&buf, _("Show Timeline in Channellist"), &maxlen, &pos);
4291        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"showchanneltimeline\" border=\"0\">", &maxlen, &pos);
4292       
4293        if(getconfigint("showchanneltimeline", NULL) == 0)
4294                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
4295        else
4296                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
4297        ostrcatbig(&buf, _("no"), &maxlen, &pos);
4298        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4299
4300        if(getconfigint("showchanneltimeline", NULL) == 1)
4301                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
4302        else
4303                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
4304        ostrcatbig(&buf, _("yes"), &maxlen, &pos);
4305        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4306       
4307        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4308        sendstr = ostrcat(sendstr, ", showchanneltimeline.value", 1 , 0);
4309
4310///////////////////
4311        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4312        ostrcatbig(&buf, _("Animated Screens"), &maxlen, &pos);
4313        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"screenanim\" border=\"0\">", &maxlen, &pos);
4314       
4315        if(getconfigint("screenanim", NULL) == 0)
4316                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
4317        else
4318                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
4319        ostrcatbig(&buf, _("no"), &maxlen, &pos);
4320        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4321
4322        if(getconfigint("screenanim", NULL) == 1)
4323                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
4324        else
4325                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
4326        ostrcatbig(&buf, _("anim. width"), &maxlen, &pos);
4327        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4328
4329        if(getconfigint("screenanim", NULL) == 2)
4330                ostrcatbig(&buf, "<option value=\"2\" selected>", &maxlen, &pos);               
4331        else
4332                ostrcatbig(&buf, "<option value=\"2\">", &maxlen, &pos);
4333        ostrcatbig(&buf, _("anim. height"), &maxlen, &pos);
4334        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4335
4336        if(getconfigint("screenanim", NULL) == 3)
4337                ostrcatbig(&buf, "<option value=\"3\" selected>", &maxlen, &pos);               
4338        else
4339                ostrcatbig(&buf, "<option value=\"3\">", &maxlen, &pos);
4340        ostrcatbig(&buf, _("anim. both"), &maxlen, &pos);
4341        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4342       
4343        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4344        sendstr = ostrcat(sendstr, ", screenanim.value", 1 , 0);
4345
4346///////////////////
4347        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4348        ostrcatbig(&buf, _("Animated Speed"), &maxlen, &pos);
4349        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"screenanimspeed\" border=\"0\">", &maxlen, &pos);
4350       
4351        if(getconfigint("screenanimspeed", NULL) == 1)
4352                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
4353        else
4354                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
4355        ostrcatbig(&buf, _("very fast"), &maxlen, &pos);
4356        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4357
4358        if(getconfigint("screenanimspeed", NULL) == 5)
4359                ostrcatbig(&buf, "<option value=\"5\" selected>", &maxlen, &pos);               
4360        else
4361                ostrcatbig(&buf, "<option value=\"5\">", &maxlen, &pos);
4362        ostrcatbig(&buf, _("fast"), &maxlen, &pos);
4363        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4364
4365        if(getconfigint("screenanimspeed", NULL) == 10)
4366                ostrcatbig(&buf, "<option value=\"10\" selected>", &maxlen, &pos);             
4367        else
4368                ostrcatbig(&buf, "<option value=\"10\">", &maxlen, &pos);
4369        ostrcatbig(&buf, _("normal"), &maxlen, &pos);
4370        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4371
4372        if(getconfigint("screenanimspeed", NULL) == 15)
4373                ostrcatbig(&buf, "<option value=\"15\" selected>", &maxlen, &pos);             
4374        else
4375                ostrcatbig(&buf, "<option value=\"15\">", &maxlen, &pos);
4376        ostrcatbig(&buf, _("slow"), &maxlen, &pos);
4377        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4378
4379        if(getconfigint("screenanimspeed", NULL) == 20)
4380                ostrcatbig(&buf, "<option value=\"20\" selected>", &maxlen, &pos);             
4381        else
4382                ostrcatbig(&buf, "<option value=\"20\">", &maxlen, &pos);
4383        ostrcatbig(&buf, _("very slow"), &maxlen, &pos);
4384        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4385       
4386        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4387        sendstr = ostrcat(sendstr, ", screenanimspeed.value", 1 , 0);
4388
4389///////////////////
4390        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4391        ostrcatbig(&buf, _("Channellist view"), &maxlen, &pos);
4392        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"channellistview\" border=\"0\">", &maxlen, &pos);
4393       
4394        if(getconfigint("channellistview", NULL) == 0)
4395                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
4396        else
4397                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
4398        ostrcatbig(&buf, _("hidden"), &maxlen, &pos);
4399        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4400
4401        if(getconfigint("channellistview", NULL) == 1)
4402                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
4403        else
4404                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
4405        ostrcatbig(&buf, _("deaktiv"), &maxlen, &pos);
4406        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4407       
4408        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4409        sendstr = ostrcat(sendstr, ", channellistview.value", 1 , 0);
4410
4411///////////////////
4412        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4413        ostrcatbig(&buf, _("Show last pos Question"), &maxlen, &pos);
4414        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"showlastpos\" border=\"0\">", &maxlen, &pos);
4415       
4416        if(getconfigint("showlastpos", NULL) == 0)
4417                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
4418        else
4419                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
4420        ostrcatbig(&buf, _("no"), &maxlen, &pos);
4421        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4422
4423        if(getconfigint("showlastpos", NULL) == 1)
4424                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
4425        else
4426                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
4427        ostrcatbig(&buf, _("yes"), &maxlen, &pos);
4428        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4429       
4430        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4431        sendstr = ostrcat(sendstr, ", showlastpos.value", 1 , 0);
4432
4433///////////////////
4434        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4435        ostrcatbig(&buf, _("Resync Recording immediately"), &maxlen, &pos);
4436        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"recsync\" border=\"0\">", &maxlen, &pos);
4437       
4438        if(getconfigint("recsync", NULL) == 0)
4439                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
4440        else
4441                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
4442        ostrcatbig(&buf, _("no"), &maxlen, &pos);
4443        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4444
4445        if(getconfigint("recsync", NULL) == 1)
4446                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
4447        else
4448                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
4449        ostrcatbig(&buf, _("yes"), &maxlen, &pos);
4450        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4451       
4452        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4453        sendstr = ostrcat(sendstr, ", recsync.value", 1 , 0);
4454
4455///////////////////
4456        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4457        ostrcatbig(&buf, _("Recording name"), &maxlen, &pos);
4458        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"recordnamefmt\" border=\"0\">", &maxlen, &pos);
4459       
4460        if(getconfigint("recordnamefmt", NULL) == 0)
4461                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
4462        else
4463                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
4464        ostrcatbig(&buf, _("channel-movie"), &maxlen, &pos);
4465        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4466
4467        if(getconfigint("recordnamefmt", NULL) == 1)
4468                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
4469        else
4470                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
4471        ostrcatbig(&buf, _("movie-channel"), &maxlen, &pos);
4472        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4473       
4474        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4475        sendstr = ostrcat(sendstr, ", recordnamefmt.value", 1 , 0);
4476
4477///////////////////
4478        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4479        ostrcatbig(&buf, _("Newsletter"), &maxlen, &pos);
4480        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"newsletter\" border=\"0\">", &maxlen, &pos);
4481       
4482        if(getconfigint("newsletter", NULL) == 0)
4483                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
4484        else
4485                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
4486        ostrcatbig(&buf, _("no"), &maxlen, &pos);
4487        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4488
4489        if(getconfigint("newsletter", NULL) == 1)
4490                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
4491        else
4492                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
4493        ostrcatbig(&buf, _("yes"), &maxlen, &pos);
4494        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4495       
4496        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4497        sendstr = ostrcat(sendstr, ", newsletter.value", 1 , 0);
4498
4499///////////////////
4500        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4501        ostrcatbig(&buf, _("Show hidden files"), &maxlen, &pos);
4502        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"showhiddenfiles\" border=\"0\">", &maxlen, &pos);
4503       
4504        if(getconfigint("showhiddenfiles", NULL) == 0)
4505                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
4506        else
4507                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
4508        ostrcatbig(&buf, _("no"), &maxlen, &pos);
4509        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4510
4511        if(getconfigint("showhiddenfiles", NULL) == 1)
4512                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
4513        else
4514                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
4515        ostrcatbig(&buf, _("yes"), &maxlen, &pos);
4516        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4517       
4518        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4519        sendstr = ostrcat(sendstr, ", showhiddenfiles.value", 1 , 0);
4520
4521///////////////////
4522        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4523        ostrcatbig(&buf, _("Expert Modus"), &maxlen, &pos);
4524        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"expertmodus\" border=\"0\">", &maxlen, &pos);
4525       
4526        if(getconfigint("expertmodus", NULL) == 0)
4527                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
4528        else
4529                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
4530        ostrcatbig(&buf, _("no"), &maxlen, &pos);
4531        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4532
4533        if(getconfigint("expertmodus", NULL) == 10)
4534                ostrcatbig(&buf, "<option value=\"10\" selected>", &maxlen, &pos);             
4535        else
4536                ostrcatbig(&buf, "<option value=\"10\">", &maxlen, &pos);
4537        ostrcatbig(&buf, _("yes"), &maxlen, &pos);
4538        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4539
4540        if(getconfigint("expertmodus", NULL) == 11)
4541                ostrcatbig(&buf, "<option value=\"11\" selected>", &maxlen, &pos);             
4542        else
4543                ostrcatbig(&buf, "<option value=\"11\">", &maxlen, &pos);
4544        ostrcatbig(&buf, _("expert (11)"), &maxlen, &pos);
4545        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4546       
4547        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4548        sendstr = ostrcat(sendstr, ", expertmodus.value", 1 , 0);
4549
4550///////////////////
4551        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4552        ostrcatbig(&buf, _("Show infobar on program change"), &maxlen, &pos);
4553        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"infobarprogram\" border=\"0\">", &maxlen, &pos);
4554       
4555        if(getconfigint("infobarprogram", NULL) == 0)
4556                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
4557        else
4558                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
4559        ostrcatbig(&buf, _("no"), &maxlen, &pos);
4560        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4561
4562        if(getconfigint("infobarprogram", NULL) == 1)
4563                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
4564        else
4565                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
4566        ostrcatbig(&buf, _("yes"), &maxlen, &pos);
4567        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4568       
4569        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4570        sendstr = ostrcat(sendstr, ", infobarprogram.value", 1 , 0);
4571
4572///////////////////
4573        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4574        ostrcatbig(&buf, _("Use cross control for fast zapping and vol"), &maxlen, &pos);
4575        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"crosscontrol\" border=\"0\">", &maxlen, &pos);
4576       
4577        if(getconfigint("crosscontrol", NULL) == 0)
4578                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
4579        else
4580                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
4581        ostrcatbig(&buf, _("no"), &maxlen, &pos);
4582        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4583
4584        if(getconfigint("crosscontrol", NULL) == 1)
4585                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
4586        else
4587                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
4588        ostrcatbig(&buf, _("yes"), &maxlen, &pos);
4589        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4590
4591        if(getconfigint("crosscontrol", NULL) == 2)
4592                ostrcatbig(&buf, "<option value=\"2\" selected>", &maxlen, &pos);               
4593        else
4594                ostrcatbig(&buf, "<option value=\"2\">", &maxlen, &pos);
4595        ostrcatbig(&buf, _("yes / vzap 1 sec"), &maxlen, &pos);
4596        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4597
4598        if(getconfigint("crosscontrol", NULL) == 3)
4599                ostrcatbig(&buf, "<option value=\"3\" selected>", &maxlen, &pos);               
4600        else
4601                ostrcatbig(&buf, "<option value=\"3\">", &maxlen, &pos);
4602        ostrcatbig(&buf, _("yes / vzap 2 sec"), &maxlen, &pos);
4603        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4604
4605        if(getconfigint("crosscontrol", NULL) == 9999)
4606                ostrcatbig(&buf, "<option value=\"9999\" selected>", &maxlen, &pos);           
4607        else
4608                ostrcatbig(&buf, "<option value=\"9999\">", &maxlen, &pos);
4609        ostrcatbig(&buf, _("yes / vzap endless"), &maxlen, &pos);
4610        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4611       
4612        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4613        sendstr = ostrcat(sendstr, ", crosscontrol.value", 1 , 0);
4614       
4615///////////////////
4616        if(status.security == 1)
4617        {
4618                ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4619                ostrcatbig(&buf, _("Deactivate Crypt Support on Media Playback"), &maxlen, &pos);
4620                ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"emucontrol\" border=\"0\">", &maxlen, &pos);
4621       
4622                if(getconfigint("emucontrol", NULL) == 0)
4623                        ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
4624                else
4625                        ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
4626                ostrcatbig(&buf, _("no"), &maxlen, &pos);
4627                ostrcatbig(&buf, "</option>", &maxlen, &pos);
4628
4629                if(getconfigint("emucontrol", NULL) == 1)
4630                        ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
4631                else
4632                        ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
4633                ostrcatbig(&buf, _("yes"), &maxlen, &pos);
4634                ostrcatbig(&buf, "</option>", &maxlen, &pos);
4635       
4636                ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4637                sendstr = ostrcat(sendstr, ", emucontrol.value", 1 , 0);
4638        }
4639
4640///////////////////
4641        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4642        ostrcatbig(&buf, _("Deactivate MiniTV"), &maxlen, &pos);
4643        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"choiceminitv\" border=\"0\">", &maxlen, &pos);
4644       
4645        if(getconfigint("choiceminitv", NULL) == 0)
4646                ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
4647        else
4648                ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
4649        ostrcatbig(&buf, _("no"), &maxlen, &pos);
4650        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4651
4652        if(getconfigint("choiceminitv", NULL) == 1)
4653                ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
4654        else
4655                ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
4656        ostrcatbig(&buf, _("yes"), &maxlen, &pos);
4657        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4658       
4659        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4660        sendstr = ostrcat(sendstr, ", choiceminitv.value", 1 , 0);
4661
4662///////////////////
4663        if(checkbox("ATEMIO510") == 1 || checkbox("UFS912") == 1 || checkbox("ATEMIO7600") == 1 || checkbox("ATEMIO520") == 1 || checkbox("ATEMIO530") == 1)
4664        {
4665                ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4666                ostrcatbig(&buf, _("Activate CEC"), &maxlen, &pos);
4667                ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"usecec\" border=\"0\">", &maxlen, &pos);
4668       
4669                if(getconfigint("usecec", 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("usecec", 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, ", usecec.value", 1 , 0);
4685        }
4686
4687///////////////////
4688        if(checkbox("ATEMIO7600") == 1)
4689        {
4690                ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4691                ostrcatbig(&buf, _("SATA Connector"), &maxlen, &pos);
4692                ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"sataswitch\" border=\"0\">", &maxlen, &pos);
4693       
4694                if(getconfigint("sataswitch", NULL) == 0)
4695                        ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
4696                else
4697                        ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
4698                ostrcatbig(&buf, _("extern"), &maxlen, &pos);
4699                ostrcatbig(&buf, "</option>", &maxlen, &pos);
4700
4701                if(getconfigint("sataswitch", NULL) == 1)
4702                        ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
4703                else
4704                        ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
4705                ostrcatbig(&buf, _("intern"), &maxlen, &pos);
4706                ostrcatbig(&buf, "</option>", &maxlen, &pos);
4707       
4708                ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4709                sendstr = ostrcat(sendstr, ", sataswitch.value", 1 , 0);
4710        }
4711
4712///////////////////
4713//      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);
4714        max = 10;
4715        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4716        ostrcatbig(&buf, _("Time to wait after seek for fill buffer"), &maxlen, &pos);
4717        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"playerbufferseektime\" border=\"0\">", &maxlen, &pos);
4718        for(i = 1; i <= max; i++)
4719        {
4720                ostrcatbig(&buf, "<option value=\"", &maxlen, &pos);
4721                ostrcatbig(&buf, oitoa(i), &maxlen, &pos);             
4722                if(getconfigint("playerbufferseektime", NULL) == i)
4723                        ostrcatbig(&buf, "\" selected>", &maxlen, &pos);               
4724                else
4725                        ostrcatbig(&buf, "\">", &maxlen, &pos);
4726                ostrcatbig(&buf, oitoa(i), &maxlen, &pos);
4727                ostrcatbig(&buf, "</option>", &maxlen, &pos);
4728        }       
4729        ostrcatbig(&buf, "</select></td></tr>", &maxlen, &pos);
4730        sendstr = ostrcat(sendstr, ", playerbufferseektime.value", 1 , 0);
4731
4732///////////////////debuglevel
4733#ifdef BETA
4734        struct splitstr* ret2 = NULL;   
4735        tmpstr = ostrcat("10\n40\n50\n60\n70\n80\n90\n99\n100\n130\n150\n200\n250\n270\n300\n400\n900\n1000", NULL, 0, 0);
4736        tmpstr2 = ostrcat(" - Minimal\n - TopfieldVFD\n - MediaCenter\n - Menulist\n  - Network Browser\n - Harddisk\n - Screensaver\n - Tithek\n - Global\n - TPK\n - ePlayer\n - Tuning\n - Stream/Record/Softcam\n - EPG\n - Radiotext\n - Subtitle\n - Mutex\n - Function", NULL, 0, 0);
4737
4738        ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4739        ostrcatbig(&buf, _("debuglevel"), &maxlen, &pos);
4740        ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"debuglevel\" border=\"0\">", &maxlen, &pos);
4741
4742        count = 0;
4743        ret1 = strsplit(tmpstr, "\n", &count);
4744        count = 0;     
4745        ret2 = strsplit(tmpstr2, "\n", &count);
4746        max = count - 1;
4747
4748        if(ret1 != NULL)
4749        {
4750                for(i = 0; i <= max; i++)
4751                {
4752                        ostrcatbig(&buf, "<option value=\"", &maxlen, &pos);
4753                        ostrcatbig(&buf, ret1[i].part, &maxlen, &pos);         
4754                        tmpstr1 = ostrcat(ret1[i].part, NULL, 0, 0);
4755                        if(getconfigint("debuglevel", NULL) == atoi(tmpstr1))
4756                                ostrcatbig(&buf, "\" selected>", &maxlen, &pos);               
4757                        else
4758                                ostrcatbig(&buf, "\">", &maxlen, &pos);
4759                        ostrcatbig(&buf, ret1[i].part, &maxlen, &pos);
4760                        ostrcatbig(&buf, ret2[i].part, &maxlen, &pos);
4761                        ostrcatbig(&buf, "</option>", &maxlen, &pos);
4762                }
4763        }
4764        ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos);
4765        sendstr = ostrcat(sendstr, ", debuglevel.value", 1 , 0);
4766        free(ret1), ret1 = NULL;
4767        free(ret2), ret2 = NULL;
4768        free(tmpstr), tmpstr = NULL;
4769        free(tmpstr1), tmpstr1 = NULL;
4770        free(tmpstr2), tmpstr2 = NULL;
4771#endif
4772       
4773///////////////////     
4774#ifdef MIPSEL
4775        if(file_exist("/usr/bin/enigma2"))
4776        {
4777                ostrcatbig(&buf, "<tr><td><font class=\"label\">", &maxlen, &pos);
4778                ostrcatbig(&buf, _("Dualboot Menu TitanNit / E2"), &maxlen, &pos);
4779                ostrcatbig(&buf, "&nbsp;</font></td><td><select name=\"dualboot\" border=\"0\">", &maxlen, &pos);
4780       
4781        //              if(getconfigint("dualboot", NULL) == 0)
4782                if(!file_exist("/mnt/config/dualboot"))
4783                        ostrcatbig(&buf, "<option value=\"0\" selected>", &maxlen, &pos);               
4784                else
4785                        ostrcatbig(&buf, "<option value=\"0\">", &maxlen, &pos);
4786                ostrcatbig(&buf, _("no"), &maxlen, &pos);
4787                ostrcatbig(&buf, "</option>", &maxlen, &pos);
4788       
4789        //              if(getconfigint("dualboot", NULL) == 1)
4790                if(file_exist("/mnt/config/dualboot"))
4791                        ostrcatbig(&buf, "<option value=\"1\" selected>", &maxlen, &pos);               
4792                else
4793                        ostrcatbig(&buf, "<option value=\"1\">", &maxlen, &pos);
4794                ostrcatbig(&buf, _("yes"), &maxlen, &pos);
4795                ostrcatbig(&buf, "</option>", &maxlen, &pos);
4796       
4797                ostrcatbig(&buf,"</select></td></tr>", &maxlen, &pos); 
4798                sendstr = ostrcat(sendstr, ", dualboot.value", 1 , 0);
4799        }
4800#endif
4801       
4802
4803//      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);
4804//      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);
4805// sendstr verwenden
4806        ostrcatbig(&buf, "</table><br><br><input class=button type=submit name=send value=\"Send\" onClick=\"return ", &maxlen, &pos);
4807        ostrcatbig(&buf, sendstr, &maxlen, &pos);
4808        ostrcatbig(&buf, "\"></input>&nbsp;<input class=button type=reset name=reset value=\"Reset\"></input></form></center></body></html>", &maxlen, &pos);
4809       
4810       
4811//writesys("/tmp/tmpstr", buf, 1);
4812        //ostrcatbig(&buf, param, &maxlen, &pos);
4813        return buf;
4814}
4815
4816char* webadjustsend(char* param, int fmt)
4817{
4818        debug(77, "fmt: %d param: %s",fmt , param);
4819
4820        char* buf = NULL;
4821        char* tmpstr = NULL, *tmpstr1 = NULL;
4822
4823        int count, count2,  max, i;
4824
4825        tmpstr = ostrcat(param, NULL, 0, 0);
4826       
4827        count = 0;
4828        struct splitstr* ret1 = NULL;
4829        ret1 = strsplit(tmpstr, "&", &count);
4830        max = count - 1;
4831       
4832        if(ret1 != NULL)
4833        {
4834                for(i = 0; i <= max; i++)
4835                {
4836                        if(ostrcmp(ret1[i].part, "node=0") == 0 || ostrcmp(ret1[i].part, "send=Send") == 0)
4837                        {
4838                                debug(77, "skip: %s", ret1[i].part);
4839                                continue;
4840                        }
4841                        tmpstr1 = ostrcat(ret1[i].part, NULL, 0, 0);
4842                        count2 = 0;
4843                        struct splitstr* ret2 = NULL;
4844                        ret2 = strsplit(tmpstr1, "=", &count2);
4845                        if(ret2 != NULL && count2 > 1)
4846                        {
4847                                if(ret2[1].part != NULL && ostrcmp(ret2[0].part, "dualboot") == 0)
4848                                {
4849                                        debug(77, "add %s: %s", ret2[0].part, ret2[1].part);
4850                                        if(ostrcmp(ret2[1].part, "0") == 0)
4851                                        {
4852                                                debug(77, "unlink /mnt/config/dualboot");
4853                                                unlink("/mnt/config/dualboot");
4854                                        }
4855                                        else
4856                                        {
4857                                                debug(77, "touch /mnt/config/dualboot");
4858                                                system("touch /mnt/config/dualboot");
4859                                        }
4860                                }
4861                                else if(ret2[1].part != NULL)
4862                                {
4863                                        debug(77, "add %s: %s", ret2[0].part, ret2[1].part);
4864                                        addconfigtmp(ret2[0].part, ret2[1].part);
4865                                }
4866
4867                        }
4868                        free(ret2), ret2 = NULL;
4869                        free(tmpstr1), tmpstr1 = NULL;
4870                }
4871        }
4872        free(ret1), ret1 = NULL;
4873        free(tmpstr), tmpstr = NULL;
4874       
4875        buf = webadjust(NULL, fmt);
4876        writeconfigtmp();
4877        writeallconfig(1);
4878#ifdef BETA
4879setdebuglevel();
4880#endif
4881        return buf;
4882}
4883
4884char* webgetparamvalue(char* param, char* searchparam)
4885{
4886        char* buf = NULL;
4887        char* tmpstr = NULL;
4888       
4889        tmpstr = ostrcat(param, NULL, 0, 0);
4890        if(tmpstr != NULL) buf = ostrstr(tmpstr, searchparam);
4891        if(buf != NULL) buf = buf + strlen(searchparam);
4892        free(tmpstr); tmpstr = NULL;
4893        buf = stringreplacecharonce(buf, '&', '\0');
4894        debug(77, "webgetparamvalue param: %s", param);
4895        debug(77, "webgetparamvalue search: %s", searchparam);
4896        debug(77, "webgetparamvalue value: %s", buf);
4897        return buf;
4898}
4899
4900char* webgetcommand(char* param, int fmt)
4901{
4902        char* buf = NULL, *tmpstr = NULL;
4903        if(param == NULL) return NULL;
4904        if(status.security == 0) return NULL;
4905
4906//      if(fmt == 0)
4907//      {
4908                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
4909                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
4910                buf = ostrcat(buf, "</head><body class=body id=\"command\"><center>", 1, 0);
4911//      }
4912
4913        debug(10, "cmd: %s", param);
4914        tmpstr = command(param);
4915        buf = ostrcat(buf, tmpstr, 1, 0);
4916        free(tmpstr), tmpstr = NULL;   
4917
4918        buf = string_replace_all("\n", "<br>", buf, 1);
4919        buf = string_replace_all("<br>", "<br>\n", buf, 1);
4920
4921//      if(fmt == 0)
4922                buf = ostrcat(buf, "</center></body></html>", 1, 0);
4923
4924        return buf;
4925}
4926
4927char* webgetsystem(char* param, int fmt)
4928{
4929        char* buf = NULL;
4930        int ret = 0;
4931        if(param == NULL) return NULL;
4932        if(status.security == 0) return NULL;
4933
4934//      if(fmt == 0)
4935//      {
4936                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
4937                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
4938                buf = ostrcat(buf, "</head><body class=body id=\"system\"><center>", 1, 0);
4939                buf = ostrcat(buf, "<h1>", 1, 0);
4940//      }
4941
4942        debug(10, "cmd: %s", param);
4943        ret = system(param);
4944
4945        if(ret != 0)
4946                buf = ostrcat(buf, _("Error, Program not started."), 1, 0);
4947        else
4948                buf = ostrcat(buf, _("Program started successfully"), 1, 0);
4949        buf = ostrcat(buf, "<br>", 1, 0);
4950
4951        buf = string_replace_all("<br>", "<br>\n", buf, 1);
4952
4953//      if(fmt == 0)
4954                buf = ostrcat(buf, "</h1></center></body></html>", 1, 0);
4955
4956        return buf;
4957}
4958
4959char* webgethelp(char* param, int fmt)
4960{
4961        char* buf = NULL, *tmpstr = NULL, *tmpstr1 = NULL, *helppath = NULL, *lang = NULL;
4962        if(param == NULL) return NULL;
4963
4964//      if(fmt == 0)
4965//      {
4966                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
4967                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
4968                buf = ostrcat(buf, "</head><body class=body id=\"help\"><center>", 1, 0);
4969                buf = ostrcat(buf, "<br>", 1, 0);
4970                buf = ostrcat(buf, "<h1>", 1, 0);
4971                buf = ostrcat(buf, _(param), 1, 0);
4972                buf = ostrcat(buf, "</h1>", 1, 0);
4973                buf = ostrcat(buf, "<br>", 1, 0);
4974//      }
4975
4976        helppath = getconfig("helppath", NULL);
4977        if(helppath == NULL) return NULL;
4978
4979        //get language
4980        lang = ostrcat(getconfig("lang", NULL), NULL, 0, 0);
4981        lang = string_replace("po/", "", lang, 1);
4982
4983        //create full filename
4984        tmpstr = ostrcat(helppath, "/", 0, 0);
4985        tmpstr = ostrcat(tmpstr, lang, 1, 0);
4986        tmpstr = ostrcat(tmpstr, "/", 1, 0);
4987        tmpstr = ostrcat(tmpstr, param, 1, 0);
4988        tmpstr = ostrcat(tmpstr, ".txt", 1, 0);
4989       
4990        debug(10, "file: %s", tmpstr);
4991        tmpstr1 = readfiletomem(tmpstr, 1);
4992
4993        buf = ostrcat(buf, _(tmpstr1), 1, 0);
4994
4995// segfault ??
4996//      free(helppath), helppath = NULL;
4997
4998        free(lang), lang = NULL;
4999        free(tmpstr), tmpstr = NULL;
5000        free(tmpstr1), tmpstr1 = NULL;
5001        buf = string_replace_all("<br>", "<br>\n", buf, 1);
5002
5003//      if(fmt == 0)
5004                buf = ostrcat(buf, "</center></body></html>", 1, 0);
5005
5006        return buf;
5007}
5008
5009char* webgethelpchoices(int fmt)
5010{
5011        char* buf = NULL, *tmpstr = NULL, *helppath = NULL, *lang = NULL, *cmd = NULL;
5012       
5013//      if(fmt == 0)
5014//      {
5015                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
5016                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
5017                buf = ostrcat(buf, "</head><body class=body id=\"helpchoices\"><center>", 1, 0);
5018                buf = ostrcat(buf, "<br>", 1, 0);
5019                buf = ostrcat(buf, "<h1>", 1, 0);
5020                buf = ostrcat(buf, _("Help"), 1, 0);
5021                buf = ostrcat(buf, "</h1>", 1, 0);
5022                buf = ostrcat(buf, "<br>", 1, 0);
5023//      }
5024
5025        helppath = getconfig("helppath", NULL);
5026        if(helppath == NULL) return NULL;
5027
5028        //get language
5029        lang = ostrcat(getconfig("lang", NULL), NULL, 0, 0);
5030        lang = string_replace("po/", "", lang, 1);
5031
5032        //create full filename
5033        cmd = ostrcat("ls -1 ", helppath, 0, 0);
5034        cmd = ostrcat(cmd, "/", 1, 0);
5035        cmd = ostrcat(cmd, lang, 1, 1);
5036        cmd = ostrcat(cmd, "/", 1, 0);
5037       
5038        debug(10, "cmd: %s", cmd);
5039        tmpstr = command(cmd);
5040       
5041        int count, i, max;
5042        count = 0;
5043        struct splitstr* ret1 = NULL;
5044        ret1 = strsplit(tmpstr, "\n", &count);
5045        max = count - 1;
5046       
5047        buf = ostrcat(buf, "<table cellpadding=5 cellspacing=5><tr><td nowrap>", 1, 0);
5048 
5049        if(ret1 != NULL)
5050        {
5051                for(i = 0; i <= max; i++)
5052                {
5053                        buf = ostrcat(buf, "<a class=linelink2 href=queryraw?gethelp&", 1, 0);
5054                        buf = ostrcat(buf, stringreplacecharonce(ret1[i].part, '.', '\0'), 1, 0);
5055                        buf = ostrcat(buf, " target=main>", 1, 0);
5056                        buf = ostrcat(buf, _(stringreplacecharonce(ret1[i].part, '.', '\0')), 1, 0);
5057                        buf = ostrcat(buf, "</a>", 1, 0);
5058                        buf = ostrcat(buf, "</br></br>", 1, 0);
5059                }
5060        }               
5061
5062// segfault ??
5063//      free(helppath), helppath = NULL;
5064        free(ret1), ret1 = NULL;
5065
5066        free(tmpstr), tmpstr = NULL;
5067        buf = string_replace_all("<br>", "<br>\n", buf, 1);
5068
5069//      if(fmt == 0)
5070                buf = ostrcat(buf, "</td></tr></table></center></body></html>", 1, 0);
5071
5072        return buf;
5073}
5074
5075char* webgettestpage(char* param, int fmt)
5076{
5077        char* buf = NULL, *tmpstr = NULL;
5078        if(param == NULL) return NULL;
5079        if(status.security == 0) return NULL;
5080
5081//      if(fmt == 0)
5082//      {
5083                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
5084                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
5085                buf = ostrcat(buf, "</head><body class=body id=\"help\"><center>", 1, 0);
5086//      }
5087       
5088        debug(10, "file: %s", param);
5089        tmpstr = readfiletomem(param, 1);
5090
5091        buf = ostrcat(buf, tmpstr, 1, 0);
5092
5093        free(tmpstr), tmpstr = NULL;   
5094        buf = string_replace_all("<br>", "<br>\n", buf, 1);
5095
5096//      if(fmt == 0)
5097                buf = ostrcat(buf, "</center></body></html>", 1, 0);
5098
5099        debug(10, "buf: %s", buf);
5100
5101        return buf;
5102}
5103
5104char* webgetsysteminfos(char* param, int fmt)
5105{
5106        char* buf = NULL, *tmpstr = NULL;
5107        int mode;
5108
5109        mode = atoi(param);
5110        if(fmt == 0)
5111        {
5112                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
5113                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
5114                buf = ostrcat(buf, "</head><body class=body id=\"systeminfos\"><center>", 1, 0);
5115                buf = ostrcat(buf, "<br>", 1, 0);
5116                buf = ostrcat(buf, "<h1>", 1, 0);
5117                if(mode == 0)
5118                        buf = ostrcat(buf, _("System Status"), 1, 0);
5119                else if(mode == 1)
5120                        buf = ostrcat(buf, _("Free Space"), 1, 0);
5121                else if(mode == 2)
5122                        buf = ostrcat(buf, _("Kernel"), 1, 0);
5123                else if(mode == 3)
5124                        buf = ostrcat(buf, _("Mounts"), 1, 0);
5125                else if(mode == 4)
5126                        buf = ostrcat(buf, _("Network"), 1, 0);
5127                else if(mode == 5)
5128                        buf = ostrcat(buf, _("Ram"), 1, 0);
5129
5130                buf = ostrcat(buf, "</h1>", 1, 0);
5131                buf = ostrcat(buf, "<br>", 1, 0);
5132        }
5133
5134        tmpstr = system_infos(mode);
5135        tmpstr = string_replace_all("\n", "<br>", tmpstr, 1);
5136
5137        buf = ostrcat(buf, tmpstr, 1, 0);
5138
5139        free(tmpstr), tmpstr = NULL;
5140        buf = string_replace_all("<br>", "<br>\n", buf, 1);
5141
5142        if(fmt == 0)
5143        {
5144                buf = ostrcat(buf, "</center></body></html>", 1, 0);
5145        }       
5146       
5147        return buf;
5148}       
5149
5150char* webgetsysinfos(char* param, int fmt)
5151{
5152        char* buf = NULL, *tmpstr = NULL;
5153        int mode;
5154
5155        mode = atoi(param);
5156        if(fmt == 0)
5157        {
5158                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
5159                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
5160                buf = ostrcat(buf, "</head><body class=body id=\"sysinfos\"><center>", 1, 0);
5161                buf = ostrcat(buf, "<br>", 1, 0);
5162                buf = ostrcat(buf, "<h1>", 1, 0);
5163                if(mode == 0)
5164                        buf = ostrcat(buf, _("CPU"), 1, 0);
5165                else if(mode == 1)
5166                        buf = ostrcat(buf, _("Memory"), 1, 0);
5167                else if(mode == 2)
5168                        buf = ostrcat(buf, _("MTD"), 1, 0);
5169                else if(mode == 3)
5170                        buf = ostrcat(buf, _("Module"), 1, 0);
5171                else if(mode == 4)
5172                        buf = ostrcat(buf, _("Devices"), 1, 0);
5173                else if(mode == 5)
5174                        buf = ostrcat(buf, _("Swap"), 1, 0);
5175                else if(mode == 6)
5176                        buf = ostrcat(buf, _("Top"), 1, 0);
5177                else if(mode == 7)
5178                        buf = ostrcat(buf, _("Prozesslist"), 1, 0);
5179                else if(mode == 8)
5180                        buf = ostrcat(buf, _("USB"), 1, 0);
5181
5182                buf = ostrcat(buf, "</h1>", 1, 0);
5183                buf = ostrcat(buf, "<br>", 1, 0);
5184        }
5185
5186        tmpstr = system_infos_sysinfo(mode);
5187        tmpstr = string_replace_all("\n", "<br>", tmpstr, 1);
5188
5189        buf = ostrcat(buf, tmpstr, 1, 0);
5190
5191        free(tmpstr), tmpstr = NULL;
5192        buf = string_replace_all("<br>", "<br>\n", buf, 1);
5193
5194        if(fmt == 0)
5195        {
5196                buf = ostrcat(buf, "</center></body></html>", 1, 0);
5197        }       
5198       
5199        return buf;
5200}       
5201
5202char* webgetlogs(char* param, int fmt)
5203{
5204        char* buf = NULL, *tmpstr = NULL;
5205        int mode;
5206
5207        mode = atoi(param);
5208        if(fmt == 0)
5209        {
5210                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
5211                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
5212                buf = ostrcat(buf, "</head><body class=body id=\"logs\"><center>", 1, 0);
5213                buf = ostrcat(buf, "<br>", 1, 0);
5214                buf = ostrcat(buf, "<h1>", 1, 0);
5215                if(mode == 0)
5216                        buf = ostrcat(buf, _("Hotline"), 1, 0);
5217                else if(mode == 1)
5218                        buf = ostrcat(buf, _("Svn Changelog"), 1, 0);
5219                else if(mode == 2)
5220                        buf = ostrcat(buf, _("Git Changelog"), 1, 0);
5221                else if(mode == 3)
5222                        buf = ostrcat(buf, _("titan Log"), 1, 0);
5223                else if(mode == 4)
5224                        buf = ostrcat(buf, _("Svn Changelog Full"), 1, 0);
5225                else if(mode == 5)
5226                        buf = ostrcat(buf, _("Git Changelog Full"), 1, 0);
5227
5228                buf = ostrcat(buf, "</h1>", 1, 0);
5229                buf = ostrcat(buf, "<br>", 1, 0);
5230        }
5231
5232        tmpstr = system_logs(mode);
5233        tmpstr = string_replace_all("\n", "<br>", tmpstr, 1);
5234
5235        buf = ostrcat(buf, tmpstr, 1, 0);
5236
5237        free(tmpstr), tmpstr = NULL;
5238        buf = string_replace_all("<br>", "<br>\n", buf, 1);
5239
5240        if(fmt == 0)
5241        {
5242                buf = ostrcat(buf, "</center></body></html>", 1, 0);
5243        }       
5244       
5245        return buf;
5246}       
5247
5248char* webgetabout(int fmt)
5249{
5250        char* buf = NULL, *tmpstr = NULL;
5251
5252        if(fmt == 0)
5253        {
5254                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
5255                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
5256                buf = ostrcat(buf, "</head><body class=body id=\"about\"><center>", 1, 0);
5257                buf = ostrcat(buf, "<br>", 1, 0);
5258                buf = ostrcat(buf, "<h1>", 1, 0);
5259                buf = ostrcat(buf, _("About"), 1, 0);
5260                buf = ostrcat(buf, "</h1>", 1, 0);
5261                buf = ostrcat(buf, "<br>", 1, 0);
5262        }
5263
5264        tmpstr = getabout();
5265        tmpstr = string_replace_all("\n", "<br>", tmpstr, 1);
5266
5267        buf = ostrcat(buf, tmpstr, 1, 0);
5268
5269        free(tmpstr), tmpstr = NULL;
5270        buf = string_replace_all("<br>", "<br>\n", buf, 1);
5271
5272        if(fmt == 0)
5273        {
5274                buf = ostrcat(buf, "</center></body></html>", 1, 0);
5275        }       
5276       
5277        return buf;
5278}
5279
5280char* webgetnewsletterchoices(int fmt)
5281{
5282        char* buf = NULL;
5283
5284        if(fmt == 0)
5285        {
5286                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
5287                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
5288                buf = ostrcat(buf, "</head><body class=body id=\"newsletterchoices\"><center>", 1, 0);
5289                buf = ostrcat(buf, "<br>", 1, 0);
5290                buf = ostrcat(buf, "<h1>", 1, 0);
5291                buf = ostrcat(buf, _("Newsletter"), 1, 0);
5292                buf = ostrcat(buf, "</h1>", 1, 0);
5293                buf = ostrcat(buf, "<br>", 1, 0);
5294        }
5295
5296        buf = ostrcat(buf, "<table cellpadding=5 cellspacing=5><tr><td nowrap>", 1, 0);
5297
5298        struct newsletter* node = NULL;
5299
5300        m_lock(&status.newslettermutex, 19);
5301        long unsigned lastnewsletter = getconfiglu("lastnewsletter", NULL);
5302
5303        readnewsletter();
5304        node = newsletter;
5305
5306        while(node != NULL)
5307        {
5308                buf = ostrcat(buf, "<a class=linelink2 href=queryraw?getnewsletter&", 1, 0);
5309                buf = ostrcat(buf, oitoa(node->nr), 1, 0);
5310                buf = ostrcat(buf, " target=main>", 1, 0);
5311                buf = ostrcat(buf, node->title, 1, 0);
5312                buf = ostrcat(buf, " - ", 1, 0);
5313                buf = ostrcat(buf, node->date, 1, 0);   
5314                buf = ostrcat(buf, "</a>", 1, 0);
5315                buf = ostrcat(buf, "</br></br>", 1, 0);
5316
5317                if(node->nr > lastnewsletter)
5318                        addconfiglu("lastnewsletter", node->nr);
5319
5320                node = node->next;
5321        }
5322
5323        freenewsletter();
5324        m_unlock(&status.newslettermutex, 19);
5325
5326        buf = string_replace_all("<br>", "<br>\n", buf, 1);
5327
5328        if(fmt == 0)
5329                buf = ostrcat(buf, "</td></tr></table></center></body></html>", 1, 0);
5330       
5331        return buf;
5332}
5333
5334char* webgetnewsletter(char* param, int fmt)
5335{
5336        char* buf = NULL, *tmpstr = NULL, *tmpstr1 = NULL;
5337
5338//      if(fmt == 0)
5339//      {
5340                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
5341                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
5342                buf = ostrcat(buf, "</head><body class=body id=\"newsletter\"><center>", 1, 0);
5343//      }
5344
5345        struct newsletter* node = NULL;
5346
5347        m_lock(&status.newslettermutex, 19);
5348
5349        readnewsletter();
5350        node = newsletter;
5351
5352        while(node != NULL)
5353        {
5354                if(ostrcmp(oitoa(node->nr), param) == 0)       
5355                {
5356                        tmpstr1 = ostrcat(node->title, " - ", 0, 0);
5357                        tmpstr1 = ostrcat(tmpstr1, node->date, 1, 0);
5358                        tmpstr = ostrcat(node->text, "\n", 0, 0);
5359                        break;
5360                }
5361                node = node->next;
5362        }
5363
5364//      if(fmt == 0)
5365//      {
5366                buf = ostrcat(buf, "<br>", 1, 0);
5367                buf = ostrcat(buf, "<h1>", 1, 0);
5368                buf = ostrcat(buf, tmpstr1, 1, 0);
5369                buf = ostrcat(buf, "</h1>", 1, 0);
5370                buf = ostrcat(buf, "<br>", 1, 0);
5371//      }
5372
5373
5374        freenewsletter();
5375        m_unlock(&status.newslettermutex, 19);
5376
5377        tmpstr = string_replace_all("\n", "<br>\n", tmpstr, 1);
5378
5379        buf = ostrcat(buf, tmpstr, 1, 0);
5380
5381        free(tmpstr), tmpstr = NULL;
5382        free(tmpstr1), tmpstr1 = NULL;
5383        buf = string_replace_all("<br>", "<br>\n", buf, 1);
5384
5385//      if(fmt == 0)
5386                buf = ostrcat(buf, "</center></body></html>", 1, 0);
5387       
5388        return buf;
5389}
5390
5391char* webgetstreamingchoices(int fmt)
5392{
5393        char* buf = NULL, *tmpstr = NULL;
5394
5395        if(fmt == 0)
5396        {
5397                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
5398                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
5399                buf = ostrcat(buf, "</head><body class=body id=\"streamingchoices\"><center>", 1, 0);
5400                buf = ostrcat(buf, "<br>", 1, 0);
5401                buf = ostrcat(buf, "<h1>", 1, 0);
5402                buf = ostrcat(buf, _("Streaming"), 1, 0);
5403                buf = ostrcat(buf, "</h1>", 1, 0);
5404                buf = ostrcat(buf, "<br>", 1, 0);
5405        }
5406
5407        int count = 0;
5408        struct service* servicenode = service;
5409
5410        while(servicenode != NULL)
5411        {
5412                if(servicenode->type == RECORDSTREAM && servicenode->recname != NULL)
5413                {
5414                        buf = ostrcat(buf, "<a class=linelink2 href=queryraw?getstreaming&", 1, 0);
5415                        tmpstr = htmlencode(servicenode->recname);
5416                        buf = ostrcat(buf, tmpstr, 1, 0);
5417                        buf = ostrcat(buf, " target=main>", 1, 0);
5418                        buf = ostrcat(buf, _("stop"), 1, 0);
5419                        buf = ostrcat(buf, " - ", 1, 0);
5420                        buf = ostrcat(buf, servicenode->recname, 1, 0);
5421                        buf = ostrcat(buf, " (", 1, 0);
5422                        if(servicenode->channel != NULL && servicenode->channel->name != NULL)
5423                                buf = ostrcat(buf, servicenode->channel->name, 1, 0);
5424                        else
5425                                buf = ostrcat(buf, _("unknown"), 1, 0);
5426                        buf = ostrcat(buf, ")", 1, 0);
5427                        buf = ostrcat(buf, "</a>", 1, 0);
5428                        buf = ostrcat(buf, "</br></br>", 1, 0);
5429                        count++;
5430                        free(tmpstr), tmpstr = NULL;
5431                }
5432                servicenode = servicenode->next;
5433        }
5434
5435        if(count == 0)
5436                buf = ostrcat(buf, _("No Live Stream running"), 1, 0);
5437
5438        buf = string_replace_all("<br>", "<br>\n", buf, 1);
5439
5440        if(fmt == 0)
5441                buf = ostrcat(buf, "</center></body></html>", 1, 0);
5442       
5443        return buf;
5444}
5445
5446char* webgetstreaming(char* param, int fmt)
5447{
5448        char* buf = NULL, *tmpstr = NULL;
5449
5450//      if(fmt == 0)
5451//      {
5452                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
5453                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
5454                buf = ostrcat(buf, "</head><body class=body id=\"streaming\"><center>", 1, 0);
5455//      }
5456
5457        htmldecode(param, param);
5458
5459        struct service* servicenode = service;
5460        while(servicenode != NULL)
5461        {
5462                if(servicenode->recname != NULL && ostrcmp(servicenode->recname, param) == 0)
5463                {
5464                        tmpstr = ostrcat(tmpstr, _("stop"), 1, 0);
5465                        tmpstr = ostrcat(tmpstr, " ", 1, 0);
5466                        tmpstr = ostrcat(tmpstr, servicenode->recname, 1, 0);
5467                        tmpstr = ostrcat(tmpstr, " (", 1, 0);
5468                        if(servicenode->channel != NULL && servicenode->channel->name != NULL)
5469                                tmpstr = ostrcat(tmpstr, servicenode->channel->name, 1, 0);
5470                        else
5471                                tmpstr = ostrcat(tmpstr, _("unknown"), 1, 0);
5472                        tmpstr = ostrcat(tmpstr, ")", 1, 0);
5473                        break;
5474                }
5475                servicenode = servicenode->next;
5476        }
5477
5478//      if(fmt == 0)
5479//      {
5480                buf = ostrcat(buf, "<br>", 1, 0);
5481                buf = ostrcat(buf, "<h1>", 1, 0);
5482                buf = ostrcat(buf, tmpstr, 1, 0);
5483                buf = ostrcat(buf, "</h1>", 1, 0);
5484                buf = ostrcat(buf, "<br>", 1, 0);
5485//      }
5486
5487        servicenode = getrecordbyname(param, RECORDSTREAM);
5488        if(servicenode != NULL)
5489        {
5490                servicenode->recendtime = 1;
5491                buf = ostrcat(buf, _("Streaming succesfull stopped."), 1, 0);
5492        }
5493        else
5494                buf = ostrcat(buf, _("ERROR, Streaming can not be stopped."), 1, 0);
5495
5496        buf = string_replace_all("<br>", "<br>\n", buf, 1);
5497        free(tmpstr) , tmpstr = NULL;
5498
5499//      if(fmt == 0)
5500                buf = ostrcat(buf, "</center></body></html>", 1, 0);
5501       
5502        return buf;
5503}
5504
5505char* webgetupdatelist(char* param, int fmt)
5506{
5507        if(status.security == 0) return NULL;
5508
5509        char* buf = NULL, *tmpstr = NULL, *tmpstr1 = NULL, *cmd = NULL;
5510        int mode;
5511
5512        mode = atoi(param);
5513
5514        struct update* node = createupdatelist(mode);
5515
5516        if(fmt == 0)
5517        {
5518                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
5519                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
5520                buf = ostrcat(buf, "</head><body class=body id=\"updatelist\">", 1, 0);
5521                buf = ostrcat(buf, "<br><center>", 1, 0);
5522                buf = ostrcat(buf, "<h1>", 1, 0);
5523                buf = ostrcat(buf, _("System Update"), 1, 0);
5524                buf = ostrcat(buf, "</h1>", 1, 0);
5525                buf = ostrcat(buf, "<br>", 1, 0);
5526        }
5527
5528        tmpstr = getimgnamereal();
5529        if(tmpstr != NULL)
5530        {
5531                buf = ostrcat(buf, _("Installed:"), 1, 0);
5532                buf = ostrcat(buf, " ", 1, 0);
5533                buf = ostrcat(buf, tmpstr, 1, 1);
5534                buf = ostrcat(buf, "<br><br>", 1, 0);
5535        }
5536
5537        if(mode == 0)
5538                tmpstr = command("ls -1 /tmp/online | grep .img | sort -r");
5539        else
5540                tmpstr = command("ls -1 /tmp | grep .img | sort -r");
5541       
5542        int count, i, max;
5543        count = 0;
5544        struct splitstr* ret1 = NULL;
5545        ret1 = strsplit(tmpstr, "\n", &count);
5546        max = count - 1;
5547
5548        buf = ostrcat(buf, "<table cellpadding=5 cellspacing=5><tr><td nowrap>", 1, 0);
5549 
5550        if(ret1 != NULL)
5551        {
5552                for(i = 0; i <= max; i++)
5553                {
5554                        buf = ostrcat(buf, "<a class=linelink2 href=queryraw?getupdate&", 1, 0);
5555
5556                        if(ostrstr(ret1[i].part, "_FULL_") != NULL)
5557                        {
5558                                cmd = ostrcat(cmd, "/sbin/update.sh ", 1, 0);
5559                                cmd = ostrcat(cmd, node->type, 1, 0);
5560                                cmd = ostrcat(cmd, " ", 1, 0);
5561
5562                                cmd = ostrcat(cmd, "full ", 1, 0);
5563
5564                                if(mode == 0)
5565                                        cmd = ostrcat(cmd, "/tmp/online/", 1, 0);
5566                                else
5567                                        cmd = ostrcat(cmd, "/tmp/", 1, 0);
5568                                cmd = ostrcat(cmd, ret1[i].part, 1, 0);
5569
5570                                cmd = ostrcat(cmd, node->auth, 1, 0);
5571                                if(node->imgtype == 1)
5572                                        cmd = ostrcat(cmd, " dev beta.dyndns.tv", 1, 0);
5573                                else
5574                                        cmd = ostrcat(cmd, " release atemio.dyndns.tv", 1, 0);
5575                                if(file_exist("/var/swap"))
5576                                {
5577                                        if(!file_exist("/var/swap/logs"))
5578                                                 mkdir("/var/swap/logs", 777);
5579                               
5580                                        if(file_exist("/etc/.beta") && file_exist("/var/swap/logs"))
5581                                                cmd = ostrcat(cmd, " > /var/swap/logs/update_debug.log 2>&1", 1, 0);           
5582                                }
5583                                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)
5584                                {
5585                                        if(!file_exist("/mnt/logs"))
5586                                                 mkdir("/mnt/logs", 777);
5587                               
5588                                        if(file_exist("/etc/.beta") && file_exist("/mnt/logs"))
5589                                                cmd = ostrcat(cmd, " > /mnt/logs/update_debug.log 2>&1", 1, 0);
5590                                }
5591                                tmpstr1 = htmlencode(cmd);
5592                                buf = ostrcat(buf, tmpstr1, 1, 0);
5593                                free(tmpstr1), tmpstr1 = NULL;
5594                                free(cmd), cmd = NULL;
5595                        }
5596
5597                        buf = ostrcat(buf, " target=main>", 1, 0);
5598                        buf = ostrcat(buf, _(stringreplacecharonce(ret1[i].part, '.', '\0')), 1, 0);
5599                        buf = ostrcat(buf, "</a>", 1, 0);
5600                        buf = ostrcat(buf, "</br></br>", 1, 0);
5601                }
5602        }
5603
5604        free(tmpstr), tmpstr = NULL;
5605        free(ret1), ret1 = NULL;
5606
5607        buf = string_replace_all("<br>", "<br>\n", buf, 1);
5608
5609        if(fmt == 0)
5610                buf = ostrcat(buf, "</td></tr></table></center></body></html>", 1, 0);
5611
5612// needed ??
5613//      freeupdatelist(node);
5614
5615        return buf;
5616}
5617
5618char* webgetupdate(char* param, int fmt)
5619{
5620        if(status.security == 0) return NULL;
5621
5622        char* buf = NULL, *cmd = NULL;
5623        printf("param: %s\n",param);
5624
5625//      if(fmt == 0)
5626//      {
5627                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
5628                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
5629                buf = ostrcat(buf, "</head><body class=body id=\"updatelist\"><center>", 1, 0);
5630                buf = ostrcat(buf, "<br>", 1, 0);
5631                buf = ostrcat(buf, "<h1 id=\"updatetitle\">", 1, 0);
5632                buf = ostrcat(buf, _("System Update"), 1, 0);
5633                buf = ostrcat(buf, "</h1>", 1, 0);
5634                buf = ostrcat(buf, "<br>", 1, 0);
5635//      }
5636
5637        writeallconfig(1);
5638
5639        cmd = htmlencode(param);
5640
5641        buf = ostrcat(buf, "<title>", 1, 0);
5642        buf = ostrcat(buf, _("Message"), 1, 0);
5643        buf = ostrcat(buf, "</title>\n", 1, 0);
5644        buf = ostrcat(buf, " <script type=\"text/javascript\">\n", 1, 0);
5645        buf = ostrcat(buf, "var bRepeat=confirm(\"", 1, 0);
5646        buf = ostrcat(buf, _("starting Full Update ?"), 1, 0);
5647        buf = ostrcat(buf, "\");\n", 1, 0);
5648        buf = ostrcat(buf, "if(bRepeat==true)\n", 1, 0);
5649        buf = ostrcat(buf, "{\n", 1, 0);
5650        buf = ostrcat(buf, "document.getElementById(\"updatetitle\").innerHTML = \"", 1, 0);
5651        buf = ostrcat(buf, _("System Update started. This can take up to 5 minutes. More details on TV."), 1, 0);
5652        buf = ostrcat(buf, "\";\n", 1, 0);
5653        buf = ostrcat(buf, "window.location = \"../queryraw?getsystem&", 1, 0);
5654        buf = ostrcat(buf, cmd, 1, 0);
5655        buf = ostrcat(buf, "\";\n", 1, 0);
5656        buf = ostrcat(buf, "}\n", 1, 0);
5657        buf = ostrcat(buf, "else\n", 1, 0);
5658        buf = ostrcat(buf, "alert(\"exit\");\n", 1, 0);
5659        buf = ostrcat(buf, "</script>\n", 1, 0);
5660
5661        buf = string_replace_all("<br>", "<br>\n", buf, 1);
5662
5663        free(cmd), cmd = NULL;
5664       
5665//      if(fmt == 0)
5666                buf = ostrcat(buf, "</center></body></html>", 1, 0);
5667
5668        return buf;
5669}
5670
5671char* webgettpksection(int fmt)
5672{
5673        if(status.security == 0) return NULL;
5674
5675        char* buf = NULL;
5676
5677        if(fmt == 0)
5678        {
5679                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
5680                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
5681                buf = ostrcat(buf, "</head><body class=body id=\"tpksection\"><center>", 1, 0);
5682                buf = ostrcat(buf, "<br>", 1, 0);
5683                buf = ostrcat(buf, "<h1>", 1, 0);
5684                buf = ostrcat(buf, _("Tpk Install - select section"), 1, 0);
5685                buf = ostrcat(buf, "</h1>", 1, 0);
5686                buf = ostrcat(buf, "<br>", 1, 0);
5687        }
5688
5689        status.hangtime = 99999;
5690
5691        unlink(TPKLOG);
5692        tpkgetindex(0);
5693        tpklist();
5694
5695        struct tpk* node = tpk;
5696
5697        if(node == NULL) buf = ostrcat(buf, _("No Tpk Sections Found."), 1, 0);
5698       
5699        while(node != NULL)
5700        {
5701                if(findsectiondone(node->section) == 1)
5702                {
5703                        node = node->next;
5704                        continue;
5705                }
5706
5707                node->done = 1;
5708
5709                buf = ostrcat(buf, "<a class=linelink2 href=queryraw?gettpklist&", 1, 0);
5710                buf = ostrcat(buf, node->section, 1, 0);
5711                buf = ostrcat(buf, " target=main>", 1, 0);
5712                buf = ostrcat(buf, _(node->section), 1, 0);
5713                buf = ostrcat(buf, "</a>", 1, 0);
5714                buf = ostrcat(buf, "</br></br>", 1, 0);
5715
5716                node = node->next;
5717        }
5718
5719        freetpk();
5720
5721        buf = string_replace_all("<br>", "<br>\n", buf, 1);
5722
5723        if(fmt == 0)
5724        {
5725                buf = ostrcat(buf, "</center></body></html>", 1, 0);
5726        }       
5727
5728        tpkcleantmp(0);
5729        status.hangtime = getconfigint("hangtime", NULL);
5730       
5731        return buf;
5732}
5733
5734char* webgettpklist(char* param, int fmt)
5735{
5736        if(status.security == 0) return NULL;
5737        int skip = 0;
5738
5739        char* buf = NULL;
5740
5741//      if(fmt == 0)
5742//      {
5743                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
5744                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
5745                buf = ostrcat(buf, "</head><body class=body id=\"tpklist\"><center>", 1, 0);
5746                buf = ostrcat(buf, "<br>", 1, 0);
5747                buf = ostrcat(buf, "<h1>", 1, 0);
5748                buf = ostrcat(buf, _("Tpk Install - select file"), 1, 0);
5749                buf = ostrcat(buf, "</h1>", 1, 0);
5750                buf = ostrcat(buf, "<br>", 1, 0);
5751//      }
5752
5753        status.hangtime = 99999;
5754
5755        unlink(TPKLOG);
5756        tpkgetindex(0);
5757        tpklist();
5758
5759        struct tpk* node = tpk, *tpk_installed = NULL, *node_installed = NULL;
5760
5761        if(node == NULL) buf = ostrcat(buf, _("No Tpk Files Found."), 1, 0);
5762
5763        tpk = NULL;
5764        tpklistinstalled(0);
5765        tpk_installed = tpk;
5766        tpk = node;
5767               
5768        while(node != NULL)
5769        {
5770                node_installed = tpk_installed;
5771                skip = 0;
5772                while(node_installed != NULL)
5773                {
5774                        if(ostrcmp(node->section, node_installed->section) == 0 && ostrcmp(node->showname, node_installed->showname) == 0)
5775                        {
5776                                skip = 1;
5777                                break;
5778                        }
5779                        node_installed = node_installed->next;
5780                }
5781               
5782                //check if tpk is in section
5783                if(param != NULL && ostrcmp(node->section, param) != 0)
5784                        skip = 1;
5785
5786                if(skip == 1)
5787                {
5788                        node = node->next;
5789                        continue;
5790                }
5791
5792                buf = ostrcat(buf, "<a class=linelink2 href=queryraw?gettpkinstallpath&", 1, 0);
5793                buf = ostrcat(buf, node->filename, 1, 0);
5794                buf = ostrcat(buf, " target=main>", 1, 0);
5795                buf = ostrcat(buf, _(node->showname), 1, 0);
5796                buf = ostrcat(buf, " v.", 1, 0);
5797                buf = ostrcat(buf, oitoa(node->version), 1, 1);
5798                buf = ostrcat(buf, "</a>", 1, 0);
5799                buf = ostrcat(buf, "</br></br>", 1, 0);
5800
5801                node = node->next;
5802        }
5803
5804        freetpk();
5805        tpkcleantmp(0);
5806        status.hangtime = getconfigint("hangtime", NULL);
5807
5808        buf = string_replace_all("<br>", "<br>\n", buf, 1);
5809
5810//      if(fmt == 0)
5811//      {
5812                buf = ostrcat(buf, "</center></body></html>", 1, 0);
5813//      }       
5814       
5815        return buf;
5816}
5817
5818char* webgettpkinstallpath(char* param, int fmt)
5819{
5820        if(status.security == 0) return NULL;
5821
5822        char* buf = NULL, *tmpstr = NULL, *path = NULL, *url = NULL, *showname = NULL;
5823        int count = 0, size = 0;
5824
5825        status.hangtime = 99999;
5826
5827        unlink(TPKLOG);
5828        tpkgetindex(0);
5829        tpklist();
5830
5831        struct tpk* node = tpk;
5832
5833        while(node != NULL)
5834        {
5835                if(ostrcmp(node->filename, param) == 0)
5836                {
5837                        size = node->size;
5838                        showname = ostrcat(node->showname, NULL, 0, 0);
5839                        url = htmlencode(node->url);
5840                        path = ostrcat(node->usepath, NULL, 0, 0);
5841                        break;
5842                }
5843                node = node->next;
5844        }
5845
5846//      if(fmt == 0)
5847//      {
5848                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
5849                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
5850                buf = ostrcat(buf, "</head><body class=body id=\"tpkinstallpath\"><center>", 1, 0);
5851                buf = ostrcat(buf, "<br>", 1, 0);
5852                buf = ostrcat(buf, "<h1>", 1, 0);
5853                buf = ostrcat(buf, _("Choice Install Medium"), 1, 0);
5854                buf = ostrcat(buf, "</h1>", 1, 0);
5855                buf = ostrcat(buf, "<br>", 1, 0);
5856//      }
5857
5858        if(path == NULL || path[0] == '*' || ostrstr(path, "mnt") != NULL)
5859        {
5860                if(tpkchecksize(NULL, "/mnt/swapextensions", size) == 0)
5861                {
5862                        tmpstr = ostrcat(tmpstr, "<a class=linelink2 href=queryraw?gettpkinstall&", 1, 0);
5863                        tmpstr = ostrcat(tmpstr, param, 1, 0);
5864                        tmpstr = ostrcat(tmpstr, "&", 1, 0);
5865                        tmpstr = ostrcat(tmpstr, url, 1, 0);
5866                        tmpstr = ostrcat(tmpstr, "&", 1, 0);
5867                        tmpstr = ostrcat(tmpstr, "/mnt/swapextensions", 1, 0);
5868                        tmpstr = ostrcat(tmpstr, " target=main>", 1, 0);
5869                        tmpstr = ostrcat(tmpstr, _("Install to MNT"), 1, 0);
5870                        tmpstr = ostrcat(tmpstr, "</a>\n", 1, 0);
5871                        tmpstr = ostrcat(tmpstr, "</br></br>\n", 1, 0);
5872                        count++;
5873                }
5874        }
5875       
5876        if(path == NULL || path[0] == '*' || ostrstr(path, "var") != NULL)
5877        {
5878                if(tpkchecksize(NULL, "/var", size) == 0)
5879                {
5880                        tmpstr = ostrcat(tmpstr, "<a class=linelink2 href=queryraw?gettpkinstall&", 1, 0);
5881                        tmpstr = ostrcat(tmpstr, param, 1, 0);
5882                        tmpstr = ostrcat(tmpstr, "&", 1, 0);
5883                        tmpstr = ostrcat(tmpstr, url, 1, 0);
5884                        tmpstr = ostrcat(tmpstr, "&", 1, 0);
5885                        tmpstr = ostrcat(tmpstr, "/var", 1, 0);
5886                        tmpstr = ostrcat(tmpstr, " target=main>", 1, 0);
5887                        tmpstr = ostrcat(tmpstr, _("Install to FLASH"), 1, 0);
5888                        tmpstr = ostrcat(tmpstr, "</a>\n", 1, 0);
5889                        tmpstr = ostrcat(tmpstr, "</br></br>\n", 1, 0);
5890                        count++;
5891                }
5892        }
5893       
5894        if(path == NULL || path[0] == '*' || ostrstr(path, "swap") != NULL)
5895        {
5896                if(file_exist("/tmp/.swapextensionsdev") == 1 || file_exist("/var/swap"))
5897                {
5898                        if(tpkchecksize(NULL, "/var/swap", size) == 0)
5899                        {
5900                                tmpstr = ostrcat(tmpstr, "<a class=linelink2 href=queryraw?gettpkinstall&", 1, 0);
5901                                tmpstr = ostrcat(tmpstr, param, 1, 0);
5902                                tmpstr = ostrcat(tmpstr, "&", 1, 0);
5903                                tmpstr = ostrcat(tmpstr, url, 1, 0);
5904                                tmpstr = ostrcat(tmpstr, "&", 1, 0);
5905                                tmpstr = ostrcat(tmpstr, "/var/swap", 1, 0);
5906                                tmpstr = ostrcat(tmpstr, " target=main>", 1, 0);
5907                                tmpstr = ostrcat(tmpstr, _("Install to SWAP"), 1, 0);
5908                                tmpstr = ostrcat(tmpstr, "</a>", 1, 0);
5909                                tmpstr = ostrcat(tmpstr, "</br></br>", 1, 0);
5910                                count++;
5911                        }
5912                }
5913        }
5914
5915        if(node == NULL && tmpstr == NULL) buf = ostrcat(buf, _("No Tpk Files Found."), 1, 0);
5916        freetpk();
5917
5918        if(count == 0)
5919        {
5920                buf = ostrcat(buf, "<br>", 1, 0);
5921                buf = ostrcat(buf, _("Can't install Package. Package to big."), 1, 0);
5922        }
5923
5924        buf = ostrcat(buf, tmpstr, 1, 0);
5925
5926        buf = string_replace_all("<br>", "<br>\n", buf, 1);
5927
5928        free(tmpstr), tmpstr = NULL;
5929        free(showname), showname = NULL;
5930        free(url), url = NULL;
5931        free(path), path = NULL;
5932
5933        tpkcleantmp(0);
5934        status.hangtime = getconfigint("hangtime", NULL);
5935       
5936//      if(fmt == 0)
5937//      {
5938                buf = ostrcat(buf, "</center></body></html>", 1, 0);
5939//      }       
5940       
5941        return buf;
5942}
5943
5944char* webgettpkinstall(char* param, int fmt)
5945{
5946        if(status.security == 0) return NULL;
5947
5948        char* buf = NULL, *tmpstr = NULL, *param1 = NULL, *param2 = NULL;
5949
5950        //create param1
5951        param1 = strchr(param, '&');
5952        if(param1 != NULL)
5953                *param1++ = '\0';
5954
5955        //create param2
5956        param2 = strchr(param1, '&');
5957        if(param2 != NULL)
5958                *param2++ = '\0';
5959
5960        if(param == NULL) return NULL;
5961        if(param1 == NULL) return NULL;
5962        if(param2 == NULL) return NULL;
5963
5964        status.hangtime = 99999;
5965
5966        char* log = NULL;
5967        int tpkret = tpkgetpackage(param, param1, param2, 0, 1);
5968
5969        if(tpkret == 0)
5970                tmpstr = ostrcat(_("Tpk Install Info - Install OK"), NULL, 0, 0);
5971        else if(tpkret == 2)
5972                tmpstr = ostrcat(_("Tpk Install Info - Install ERROR"), NULL, 0, 0);
5973        else
5974                tmpstr = ostrcat(_("Tpk Install Info - Install ERROR"), NULL, 0, 0);
5975
5976//      if(fmt == 0)
5977//      {
5978                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
5979                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
5980                buf = ostrcat(buf, "</head><body class=body id=\"tpkinstall\"><center>", 1, 0);
5981                buf = ostrcat(buf, "<br>", 1, 0);
5982                buf = ostrcat(buf, "<h1>", 1, 0);
5983                buf = ostrcat(buf, _(tmpstr), 1, 0);
5984                buf = ostrcat(buf, "</h1>", 1, 0);
5985                buf = ostrcat(buf, "<br>", 1, 0);
5986                buf = ostrcat(buf, "<br>", 1, 0);
5987//      }
5988
5989        free(tmpstr), tmpstr = NULL;
5990
5991        if(tpkret == 0)
5992        {
5993                log = gettpklog(param2, 0);
5994                log = string_replace_all("\n", "<br>\n", log, 1);
5995                buf = ostrcat(buf, "<br>", 1, 0);
5996                buf = ostrcat(buf, _("Install Log:"), 1, 0);
5997                buf = ostrcat(buf, "<br>", 1, 0);
5998                buf = ostrcat(buf, "<br>", 1, 0);
5999                buf = ostrcat(buf, log, 1, 0);
6000        }
6001        else if(tpkret == 2)
6002        {
6003                buf = ostrcat(buf, "<br>", 1, 0);
6004                buf = ostrcat(buf, _("Install Log:"), 1, 0);
6005                buf = ostrcat(buf, "<br>", 1, 0);
6006                buf = ostrcat(buf, "<br>", 1, 0);
6007                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);
6008        }
6009        else
6010        {
6011                log = gettpklog(param2, 1);
6012                log = string_replace_all("\n", "<br>\n", log, 1);
6013                buf = ostrcat(buf, "<br>", 1, 0);
6014                buf = ostrcat(buf, _("Install Log:"), 1, 0);
6015                buf = ostrcat(buf, "<br>", 1, 0);
6016                buf = ostrcat(buf, "<br>", 1, 0);
6017                buf = ostrcat(buf, log, 1, 0);
6018        }
6019
6020        buf = string_replace_all("<br>", "<br>\n", buf, 1);
6021
6022        loadplugin();
6023        free(log), log = NULL;
6024        unlink(TPKLOG);
6025        if(file_exist("/tmp/.tpk_needs_reboot"))
6026        {
6027// need other..
6028                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);
6029                buf = ostrcat(buf, "<br>", 1, 0);
6030                buf = ostrcat(buf, _("TPK Install done, your system will reboot !"), 1, 0);
6031                buf = string_replace_all("<br>", "<br>\n", buf, 1);
6032                //write only config file
6033                writeallconfig(3);
6034                oshutdown(2,2);
6035                system("init 6");
6036        }
6037
6038        status.hangtime = getconfigint("hangtime", NULL);
6039
6040//      if(fmt == 0)
6041//      {
6042                buf = ostrcat(buf, "</center></body></html>", 1, 0);
6043//      }       
6044       
6045        return buf;
6046}
6047
6048char* webgettpktmplist(char* param, int fmt)
6049{
6050        if(status.security == 0) return NULL;
6051        int mode = atoi(param);
6052
6053        char* buf = NULL, *tmpstr = NULL, *tmpstr1 = NULL, *tmpstr2 = NULL, *tmpstr3 = NULL;
6054
6055        if(fmt == 0)
6056        {
6057                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
6058                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
6059                buf = ostrcat(buf, "</head><body class=body id=\"tpktmplist\"><center>", 1, 0);
6060                buf = ostrcat(buf, "<br>", 1, 0);
6061                buf = ostrcat(buf, "<h1>", 1, 0);
6062                if(mode == 0)
6063                        buf = ostrcat(buf, _("TPK tmp (tmp)"), 1, 0);
6064                else
6065                        buf = ostrcat(buf, _("TPK media (media)"), 1, 0);
6066               
6067                buf = ostrcat(buf, "</h1>", 1, 0);
6068                buf = ostrcat(buf, "<br>", 1, 0);
6069        }
6070
6071        if(mode == 0)
6072                tmpstr = gettpktmplist("/tmp");
6073        else
6074        {
6075                int treffer = 0;
6076                struct hdd *node = NULL;
6077
6078                addhddall();
6079                node = hdd;
6080       
6081                while(node != NULL)
6082                {
6083                        if(node->partition != 0)
6084                        {
6085                                tmpstr1 = ostrcat("/autofs/", node->device, 0, 0);
6086                                tmpstr2 = gettpktmplist(tmpstr1);
6087       
6088                                if(tmpstr2 != NULL)
6089                                {
6090                                        treffer = 1;
6091//                                      screenextensions(2, tmpstr1, NULL, 1);
6092                                        tmpstr3 = ostrcat(tmpstr3, tmpstr1, 1, 0);                                     
6093                                        tmpstr3 = ostrcat(tmpstr3, "\n", 1, 0);
6094                                }
6095       
6096                                free(tmpstr1); tmpstr1 = NULL;
6097                                free(tmpstr2); tmpstr2 = NULL;
6098                        }
6099                        node = node->next;
6100                }
6101       
6102                tmpstr = gettpktmplist(tmpstr3);       
6103                free(tmpstr3), tmpstr = NULL;
6104        }
6105       
6106        if(mode == 0)
6107        {
6108                if(tmpstr == NULL) buf = ostrcat(buf, _("No Tpk Files Found on /tmp Directory."), 1, 0);
6109        }
6110        else
6111        {
6112                if(tmpstr == NULL) buf = ostrcat(buf, _("No Tpk Files Found on Media Devices."), 1, 0);
6113        }
6114
6115        int count, i, max;
6116        count = 0;
6117        struct splitstr* ret1 = NULL;
6118        ret1 = strsplit(tmpstr, "\n", &count);
6119        max = count - 1;
6120
6121        buf = ostrcat(buf, "<table cellpadding=5 cellspacing=5><tr><td nowrap>", 1, 0);
6122 
6123        if(ret1 != NULL)
6124        {
6125                for(i = 0; i <= max; i++)
6126                {
6127                        buf = ostrcat(buf, "<a class=linelink2 href=queryraw?gettpkinstallpath&", 1, 0);
6128                        buf = ostrcat(buf, ret1[i].part, 1, 0);
6129                        buf = ostrcat(buf, " target=main>", 1, 0);
6130                        buf = ostrcat(buf, _(stringreplacecharonce(ret1[i].part, '.', '\0')), 1, 0);
6131                        buf = ostrcat(buf, "</a>", 1, 0);
6132                        buf = ostrcat(buf, "</br></br>", 1, 0);
6133                }
6134        }
6135
6136        free(tmpstr), tmpstr = NULL;
6137        free(ret1), ret1 = NULL;
6138
6139        buf = string_replace_all("<br>", "<br>\n", buf, 1);
6140
6141        if(fmt == 0)
6142        {
6143                buf = ostrcat(buf, "</center></body></html>", 1, 0);
6144        }       
6145       
6146        return buf;
6147}
6148
6149char* webgettpkremovelist(int fmt)
6150{
6151        if(status.security == 0) return NULL;
6152
6153        char* buf = NULL;
6154        int skip;
6155
6156//      if(fmt == 0)
6157//      {
6158                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
6159                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
6160                buf = ostrcat(buf, "</head><body class=body id=\"tpkremovelist\"><center>", 1, 0);
6161                buf = ostrcat(buf, "<br>", 1, 0);
6162                buf = ostrcat(buf, "<h1>", 1, 0);
6163                buf = ostrcat(buf, _("Tpk Remove - select file"), 1, 0);
6164                buf = ostrcat(buf, "</h1>", 1, 0);
6165                buf = ostrcat(buf, "<br>", 1, 0);
6166//      }
6167
6168        status.hangtime = 99999;
6169
6170        unlink(TPKLOG);
6171        tpkgetindex(0);
6172        tpklist();
6173
6174        struct tpk* node = tpk, *tpk_installed = NULL, *node_installed = NULL;
6175
6176        if(node == NULL) buf = ostrcat(buf, _("No Tpk Files Found."), 1, 0);
6177
6178        tpk = NULL;
6179        tpklistinstalled(0);
6180        tpk_installed = tpk;
6181        tpk = node;
6182       
6183        while(node != NULL)
6184        {
6185                node_installed = tpk_installed;
6186                skip = 1;
6187                while(node_installed != NULL)
6188                {
6189                        if(ostrcmp(node->showname, node_installed->showname) == 0)
6190                        {
6191                                skip = 0;
6192                                break;
6193                        }
6194                        node_installed = node_installed->next;
6195                }
6196
6197                if(skip == 1)
6198                {
6199                        node = node->next;
6200                        continue;
6201                }
6202
6203                buf = ostrcat(buf, "<a class=linelink2 href=queryraw?gettpkremove&", 1, 0);
6204                buf = ostrcat(buf, node->name, 1, 0);
6205                buf = ostrcat(buf, " target=main>", 1, 0);
6206                buf = ostrcat(buf, _(node->showname), 1, 0);
6207                buf = ostrcat(buf, " (", 1, 0);
6208                buf = ostrcat(buf, _(node->section), 1, 0);
6209                buf = ostrcat(buf, ")</a>", 1, 0);
6210                buf = ostrcat(buf, "</br></br>", 1, 0);
6211
6212                node = node->next;
6213        }
6214
6215        freetpk();
6216        tpkcleantmp(0);
6217        status.hangtime = getconfigint("hangtime", NULL);
6218
6219        buf = string_replace_all("<br>", "<br>\n", buf, 1);
6220
6221//      if(fmt == 0)
6222//      {
6223                buf = ostrcat(buf, "</center></body></html>", 1, 0);
6224//      }       
6225       
6226        return buf;
6227}
6228
6229char* webgettpkremove(char* param, int fmt)
6230{
6231        if(status.security == 0) return NULL;
6232
6233        char* buf = NULL, *tmpstr = NULL;
6234
6235        status.hangtime = 99999;
6236
6237        char* log = NULL;
6238
6239        int tpkret = tpkremove(param, 0, 0);
6240
6241        if(tpkret == 0)
6242        {
6243                tmpstr = ostrcat(_("Tpk Remove Info - Remove OK"), NULL, 0, 0);
6244                if(param != NULL && param[0] != '*') delplugin(param);
6245        }
6246        else
6247                tmpstr = ostrcat(_("Tpk Remove Info - Remove ERROR"), NULL, 0, 0);
6248
6249//      if(fmt == 0)
6250//      {
6251                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
6252                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
6253                buf = ostrcat(buf, "</head><body class=body id=\"tpkremove\"><center>", 1, 0);
6254                buf = ostrcat(buf, "<br>", 1, 0);
6255                buf = ostrcat(buf, "<h1>", 1, 0);
6256                buf = ostrcat(buf, _(tmpstr), 1, 0);
6257                buf = ostrcat(buf, "</h1>", 1, 0);
6258                buf = ostrcat(buf, "<br>", 1, 0);
6259                buf = ostrcat(buf, "<br>", 1, 0);
6260//      }
6261
6262        free(tmpstr), tmpstr = NULL;
6263
6264        if(tpkret == 0)
6265        {
6266                log = gettpklog(NULL, 2);
6267                log = string_replace_all("\n", "<br>\n", log, 1);
6268                buf = ostrcat(buf, "<br>", 1, 0);
6269                buf = ostrcat(buf, _("Remove Log:"), 1, 0);
6270                buf = ostrcat(buf, "<br>", 1, 0);
6271                buf = ostrcat(buf, "<br>", 1, 0);
6272                buf = ostrcat(buf, log, 1, 0);
6273        }
6274        else
6275        {
6276                log = gettpklog(NULL, 3);
6277                log = string_replace_all("\n", "<br>\n", log, 1);
6278                buf = ostrcat(buf, "<br>", 1, 0);
6279                buf = ostrcat(buf, _("Remove Log:"), 1, 0);
6280                buf = ostrcat(buf, "<br>", 1, 0);
6281                buf = ostrcat(buf, "<br>", 1, 0);
6282                buf = ostrcat(buf, log, 1, 0);
6283        }
6284
6285        buf = string_replace_all("<br>", "<br>\n", buf, 1);
6286
6287        loadplugin();
6288        free(log), log = NULL;
6289        unlink(TPKLOG);
6290        if(file_exist("/tmp/.tpk_needs_reboot"))
6291        {
6292// need other..
6293                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);
6294                buf = ostrcat(buf, "<br>", 1, 0);
6295                buf = ostrcat(buf, _("TPK Install done, your system will reboot !"), 1, 0);
6296                buf = string_replace_all("<br>", "<br>\n", buf, 1);
6297                //write only config file
6298                writeallconfig(3);
6299                oshutdown(2,2);
6300                system("init 6");
6301        }
6302
6303        status.hangtime = getconfigint("hangtime", NULL);
6304
6305//      if(fmt == 0)
6306//      {
6307                buf = ostrcat(buf, "</center></body></html>", 1, 0);
6308//      }       
6309       
6310        return buf;
6311}
6312
6313char* webgettpkupgrade(int fmt)
6314{
6315        if(status.security == 0) return NULL;
6316
6317        char* buf = NULL;
6318
6319        status.hangtime = 99999;
6320
6321        if(fmt == 0)
6322        {
6323                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
6324                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
6325                buf = ostrcat(buf, "</head><body class=body id=\"tpkupgrade\"><center>", 1, 0);
6326        }
6327
6328        if(tpkgetindex(1) != 0)
6329        {
6330                buf = ostrcat(buf, "<br>", 1, 0);
6331                buf = ostrcat(buf, "<h1>", 1, 0);
6332                buf = ostrcat(buf, _("Tpk Update Info - Update ERROR"), 1, 0);
6333                buf = ostrcat(buf, "</h1>", 1, 0);
6334                buf = ostrcat(buf, "<br>", 1, 0);
6335                buf = ostrcat(buf, _("Can't get all TPK index !"), 1, 0);
6336                buf = ostrcat(buf, "<br>", 1, 0);
6337        }
6338               
6339        writesys("/tmp/.tpk_upgrade_start", "0", 0);
6340        if(tpkupdate(0) != 0)
6341        {
6342                buf = ostrcat(buf, "<br>", 1, 0);
6343                buf = ostrcat(buf, "<h1>", 1, 0);
6344                buf = ostrcat(buf, _("Tpk Update Info - Update ERROR"), 1, 0);
6345                buf = ostrcat(buf, "</h1>", 1, 0);
6346                buf = ostrcat(buf, "<br>", 1, 0);
6347                buf = ostrcat(buf, _("Can't update all packages !"), 1, 0);
6348                buf = ostrcat(buf, "<br>", 1, 0);
6349        }
6350        else
6351        {
6352                buf = ostrcat(buf, "<br>", 1, 0);
6353                buf = ostrcat(buf, "<h1>", 1, 0);
6354                buf = ostrcat(buf, _("Tpk Update Info - Update OK"), 1, 0);
6355                buf = ostrcat(buf, "</h1>", 1, 0);
6356                buf = ostrcat(buf, "<br>", 1, 0);
6357        }
6358
6359        loadplugin();
6360        unlink(TPKLOG);
6361
6362        if(file_exist("/tmp/.tpk_needs_reboot"))
6363        {
6364                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);
6365                //write only config file
6366                writeallconfig(3);
6367                oshutdown(2,2);
6368                system("init 6");
6369        }
6370        unlink("/tmp/.tpk_upgrade_start");
6371
6372        status.hangtime = getconfigint("hangtime", NULL);
6373
6374        if(fmt == 0)
6375        {
6376                buf = ostrcat(buf, "</center></body></html>", 1, 0);
6377        }       
6378       
6379        return buf;
6380}
6381
6382char* webgetserviceinfo(int fmt)
6383{
6384        char* buf = NULL, *tmpstr = NULL;
6385
6386        if(fmt == 0)
6387        {
6388                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
6389                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
6390                buf = ostrcat(buf, "</head><body class=body id=\"serviceinfo\"><center>", 1, 0);
6391                buf = ostrcat(buf, "<br>", 1, 0);
6392                buf = ostrcat(buf, "<h1>", 1, 0);
6393                buf = ostrcat(buf, _("Service"), 1, 0);
6394                buf = ostrcat(buf, "</h1>", 1, 0);
6395                buf = ostrcat(buf, "<br>", 1, 0);
6396        }
6397
6398//      tmpstr = getabout();
6399//      readnewsletter();
6400        tmpstr = readfiletomem("/tmp/Service.txt", 0);
6401        tmpstr = ostrcat(tmpstr, "\ncomming soon...\n", 1, 0);
6402       
6403        tmpstr = string_replace_all("\n", "<br>\n", tmpstr, 1);
6404
6405        buf = ostrcat(buf, tmpstr, 1, 1);
6406
6407        if(fmt == 0)
6408        {
6409                buf = ostrcat(buf, "</center></body></html>", 1, 0);
6410        }       
6411       
6412        return buf;
6413}
6414
6415char* webgetbackup(int fmt)
6416{
6417        if(status.security == 0) return NULL;
6418
6419        char* buf = NULL, *tmpstr = NULL;
6420
6421        if(fmt == 0)
6422        {
6423                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
6424                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
6425                buf = ostrcat(buf, "</head><body class=body id=\"backup\"><center>", 1, 0);
6426                buf = ostrcat(buf, "<br>", 1, 0);
6427                buf = ostrcat(buf, "<h1>", 1, 0);
6428                buf = ostrcat(buf, _("System Backup"), 1, 0);
6429                buf = ostrcat(buf, "</h1>", 1, 0);
6430                buf = ostrcat(buf, "<br>", 1, 0);
6431        }
6432
6433//      tmpstr = getabout();
6434//      readnewsletter();
6435        tmpstr = readfiletomem("/tmp/Service.txt", 0);
6436        tmpstr = ostrcat(tmpstr, "\ncomming soon...\n", 1, 0);
6437       
6438        tmpstr = string_replace_all("\n", "<br>\n", tmpstr, 1);
6439
6440        buf = ostrcat(buf, tmpstr, 1, 1);
6441
6442        if(fmt == 0)
6443        {
6444                buf = ostrcat(buf, "</center></body></html>", 1, 0);
6445        }       
6446       
6447        return buf;
6448}
6449
6450char* webgetrestore(int fmt)
6451{
6452        if(status.security == 0) return NULL;
6453
6454        char* buf = NULL, *tmpstr = NULL;
6455
6456        if(fmt == 0)
6457        {
6458                buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", 1, 0);
6459                buf = ostrcat(buf, "<link rel=stylesheet type=text/css href=titan.css><script type=text/javascript src=titan.js></script>", 1, 0);
6460                buf = ostrcat(buf, "</head><body class=body id=\"restore\"><center>", 1, 0);
6461                buf = ostrcat(buf, "<br>", 1, 0);
6462                buf = ostrcat(buf, "<h1>", 1, 0);
6463                buf = ostrcat(buf, _("Settings backup/restore"), 1, 0);
6464                buf = ostrcat(buf, "</h1>", 1, 0);
6465                buf = ostrcat(buf, "<br>", 1, 0);
6466        }
6467
6468//      tmpstr = getabout();
6469//      readnewsletter();
6470        tmpstr = readfiletomem("/tmp/Service.txt", 0);
6471        tmpstr = ostrcat(tmpstr, "\ncomming soon...\n", 1, 0);
6472       
6473        tmpstr = string_replace_all("\n", "<br>\n", tmpstr, 1);
6474
6475        buf = ostrcat(buf, tmpstr, 1, 1);
6476
6477        if(fmt == 0)
6478        {
6479                buf = ostrcat(buf, "</center></body></html>", 1, 0);
6480        }       
6481       
6482        return buf;
6483}
6484
6485char* webstartplugin(char* param, int fmt)
6486{
6487        void (*startplugin)(void);
6488        char* buf = NULL;
6489       
6490        struct skin* pluginnode = getplugin(param);
6491       
6492        if(pluginnode != NULL)
6493        {
6494                startplugin = dlsym(pluginnode->pluginhandle, "start");
6495                if(startplugin != NULL)
6496                {
6497                        resettvpic();
6498                        startplugin();
6499                        resettvpic();
6500                        buf = ostrcat(buf, "ok", 1, 0);
6501                }
6502                else
6503                        buf = ostrcat(buf, "internal error", 1, 0);
6504        }
6505        else
6506                buf = ostrcat(buf, "wrong plugin name", 1, 0);
6507               
6508        return buf;
6509}
6510       
6511       
6512#endif
Note: See TracBrowser for help on using the repository browser.