source: titan/titan/httpdfunc.h @ 14619

Last change on this file since 14619 was 14619, checked in by gost, 12 years ago

[titan] Download videos via WebIf

File size: 67.9 KB
Line 
1#ifndef HTTPDFUNC_H
2#define HTTPDFUNC_H
3
4time_t webcreatetimeline(char** buf, int* maxlen, int* pos)
5{
6        int i = 0;
7        struct tm *loctime = NULL;
8        int timeadd = 15 * 60;
9        char* buf1 = NULL;
10        time_t akttimeadd = 0;
11
12#ifdef SIMULATE
13        time_t akttime = 1307871000;
14        akttime = 1315614961;
15#else
16        time_t akttime = time(NULL);
17#endif
18
19        akttime -= (((akttime) % 100));
20        akttime -= (((akttime / 60) % 15) * 60);
21        akttimeadd = akttime;
22
23        buf1 = malloc(6);
24        if(buf1 == NULL)
25        {
26                err("no mem");
27                return akttime;
28        }
29
30        //not shown
31        ostrcatbig(buf, "<th class=gepgchannel1> </th><th style=\"width: 1px; max-width: 1px; min-width: 1px;\"></th>", maxlen, pos);
32        for(i = 0; i < 96; i++)
33        {
34                loctime = olocaltime(&akttimeadd);
35                if(loctime != NULL)
36                        strftime(buf1, 6, "%H:%M", loctime);
37                else
38                        snprintf(buf1, 6, "00:00");
39                free(loctime); loctime = NULL;
40
41                ostrcatbig(buf, "<th class=gepgtimelinecell><div class=gepgcellborder>", maxlen, pos);
42                ostrcatbig(buf, buf1, maxlen, pos);
43                ostrcatbig(buf, "</div></th>", maxlen, pos);
44
45                akttimeadd += timeadd;
46        }
47
48        free(buf1);
49        return akttime / 60;
50}
51
52void webcreatetailbig(char** buf, int* maxlen, int* pos, int flag)
53{
54        ostrcatbig(buf, "</table></font></center></body></html>", maxlen, pos);
55}
56
57
58char* webcreatetail(char* buf, int flag)
59{
60        buf = ostrcat(buf, "</table></font></center></body></html>", 1, 0);
61        return buf;
62}
63
64void webcreateheadbig(char** buf, int* maxlen, char* meta, int* pos, int flag)
65{
66        ostrcatbig(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><link rel=stylesheet type=text/css href=titan.css>", maxlen, pos);
67        if(meta != NULL)
68                ostrcatbig(buf, meta, maxlen, pos);
69        ostrcatbig(buf, "</head><body class=body>", maxlen, pos);
70        if(flag == 0)
71                ostrcatbig(buf, "<center><table border=0 width=100%>", maxlen, pos);
72        else
73                ostrcatbig(buf, "<center><table border=0 width=100% height=100%>", maxlen, pos);
74}
75
76char* webcreatehead(char* buf, char* meta, int flag)
77{
78        buf = ostrcat(buf, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><link rel=stylesheet type=text/css href=titan.css>", 1, 0);
79        if(meta != NULL)
80                buf = ostrcat(buf, meta, 1, 0);
81        buf = ostrcat(buf, "</head><body class=body>", 1, 0);
82        if(flag == 0)
83                buf = ostrcat(buf, "<center><table border=0 width=100%>", 1, 0);
84        else
85                buf = ostrcat(buf, "<center><table border=0 width=100% height=100%>", 1, 0);
86        return buf;
87}
88
89void webcreatechannelbody(char** buf, int line, struct channel* chnode, char* channellist, int* maxlen, int* pos, int flag)
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(line == 0)
108                ostrcatbig(buf, "<tr class=line1>", maxlen, pos);
109        else
110                ostrcatbig(buf, "<tr class=line2>", maxlen, pos);
111
112
113        if(epgnode != NULL)
114        {
115                proz = (time(NULL) - epgnode->starttime) * 100 / (epgnode->endtime - epgnode->starttime);
116                if(proz > 100) proz = 100;
117                if(proz < 0) proz = 0;
118        }
119
120        ostrcatbig(buf, "<td width=100% valign=middle nowrap class=link><div class=timelineborder><div class=timelinebar style=\"width: ", maxlen, pos);
121        tmpstr = oitoa(proz);
122        ostrcatbig(buf, tmpstr, maxlen, pos);
123        free(tmpstr); tmpstr = NULL;
124        ostrcatbig(buf, "%;\"> </div></div>", maxlen, pos);
125
126        serviceid = oitoa(chnode->serviceid);
127        transponderid = olutoa(chnode->transponderid);
128
129        if(ret == 0)
130        {
131                ostrcatbig(buf, "<a target=aktservice class=link href=query?switch&", maxlen, pos);
132                ostrcatbig(buf, serviceid, maxlen, pos);
133                ostrcatbig(buf, "&", maxlen, pos);
134                ostrcatbig(buf, transponderid, maxlen, pos);
135                ostrcatbig(buf, "&", maxlen, pos);
136                ostrcatbig(buf, channellist, maxlen, pos);
137                ostrcatbig(buf, ">", maxlen, pos);
138        }
139
140        ostrcatbig(buf, chnode->name, maxlen, pos);
141        if(ret == 0) ostrcatbig(buf, "</a>", maxlen, pos);
142
143        //akt epg
144        if(epgnode != NULL)
145        {
146                if(flag == 0)
147                        ostrcatbig(buf, "<br><a target=main class=smalllink href=query?getepg&", maxlen, pos);
148                else
149                        ostrcatbig(buf, " <a target=main class=smalllink href=query?getepg&", maxlen, pos);
150
151                ostrcatbig(buf, serviceid, maxlen, pos);
152                ostrcatbig(buf, "&", maxlen, pos);
153                ostrcatbig(buf, transponderid, maxlen, pos);
154                ostrcatbig(buf, "&", maxlen, pos);
155                tmpstr = oitoa(epgnode->eventid);
156                ostrcatbig(buf, tmpstr, maxlen, pos);
157                free(tmpstr); tmpstr = NULL;
158                ostrcatbig(buf, ">", maxlen, pos);
159
160                loctime = olocaltime(&epgnode->starttime);
161                if(loctime != NULL)
162                        strftime(buf1, MINMALLOC, "%H:%M -", loctime);
163                free(loctime); loctime = NULL;
164                loctime = olocaltime(&epgnode->endtime);
165                if(loctime != NULL)
166                        strftime(&buf1[7], MINMALLOC - 8, " %H:%M ", loctime);
167                free(loctime); loctime = NULL;
168
169                ostrcatbig(buf, buf1, maxlen, pos);
170                ostrcatbig(buf, epgnode->title, maxlen, pos);
171
172                max = (epgnode->endtime - epgnode->starttime) / 60;
173                akt = (time(NULL) - epgnode->starttime) / 60;
174                if(max < 0) max = 0;
175                if(akt < 0) akt = 0;
176                snprintf(buf1, MINMALLOC, " (%ld from %ld min, %d%%)", akt, max, proz);
177                ostrcatbig(buf, buf1, maxlen, pos);
178
179                ostrcatbig(buf, "</a>", maxlen, pos);
180
181                //next epg
182                epgnode = epgnode->next;
183                if(flag == 0 && epgnode != NULL)
184                {
185                        ostrcatbig(buf, "<br><a target=main class=smalllink href=query?getepg&", maxlen, pos);
186                        ostrcatbig(buf, serviceid, maxlen, pos);
187                        ostrcatbig(buf, "&", maxlen, pos);
188                        ostrcatbig(buf, transponderid, maxlen, pos);
189                        ostrcatbig(buf, "&", maxlen, pos);
190                        tmpstr = oitoa(epgnode->eventid);
191                        ostrcatbig(buf, tmpstr, maxlen, pos);
192                        free(tmpstr); tmpstr = NULL;
193                        ostrcatbig(buf, ">", maxlen, pos);
194
195                        loctime = olocaltime(&epgnode->starttime);
196                        if(loctime != NULL)
197                                strftime(buf1, 8, "%H:%M -", loctime);
198                        free(loctime); loctime = NULL;
199                        loctime = olocaltime(&epgnode->endtime);
200                        if(loctime != NULL)
201                                strftime(&buf1[7], 8, " %H:%M ", loctime);
202                        free(loctime); loctime = NULL;
203
204                        ostrcatbig(buf, buf1, maxlen, pos);
205                        ostrcatbig(buf, epgnode->title, maxlen, pos);
206                        ostrcatbig(buf, "</a>", maxlen, pos);
207                }
208        }
209
210        //tv - radio
211        if(chnode->servicetype == 0)
212                ostrcatbig(buf, "</td><td width=100 align=right valign=middle nowrap><img style=\"margin-left: 5\" border=0 src=img/tv.png alt=TV width=16 height=16>", maxlen, pos);
213        else
214                ostrcatbig(buf, "</td><td width=100 align=right valign=middle nowrap><img style=\"margin-left: 5\" border=0 src=img/radio.png alt=Radio width=16 height=16>", maxlen, pos);
215
216        //single epg
217        ostrcatbig(buf, "<a target=main href=query?getsingleepg&", maxlen, pos);
218        ostrcatbig(buf, serviceid, maxlen, pos);
219        ostrcatbig(buf, "&", maxlen, pos);
220        ostrcatbig(buf, transponderid, maxlen, pos);
221        ostrcatbig(buf, "><img style=\"margin-left: 5\" border=0 src=img/singleepg.png alt=\"Single EPG\" width=16 height=16></a>", maxlen, pos);
222
223        //m3u stream + webstream
224        if(ret == 0)
225        {
226                ostrcatbig(buf, "<a target=nothing href=query?getm3u&", maxlen, pos);
227                ostrcatbig(buf, serviceid, maxlen, pos);
228                ostrcatbig(buf, ",", maxlen, pos);
229                ostrcatbig(buf, transponderid, maxlen, pos);
230                ostrcatbig(buf, "><img style=\"margin-left: 5\" border=0 src=img/stream.png alt=Stream width=16 height=16></a>", maxlen, pos);
231
232                ostrcatbig(buf, "<a target=_blank href=query?getvideo&", maxlen, pos);
233                ostrcatbig(buf, serviceid, maxlen, pos);
234                ostrcatbig(buf, ",", maxlen, pos);
235                ostrcatbig(buf, transponderid, maxlen, pos);
236                ostrcatbig(buf, "><img style=\"margin-left: 5\" border=0 src=img/webstream.png alt=WebStream width=16 height=16></a>", maxlen, pos);
237        }
238        else
239                ostrcatbig(buf, "<img style=\"margin-left: 5\" border=0 src=img/cross.png alt=\"Channel not availabel\" width=16 height=16>", maxlen, pos);
240        ostrcatbig(buf, "</td></tr>", maxlen, pos);
241
242        free(buf1);
243        free(serviceid);
244        free(transponderid);
245}
246
247char* webgetbouquetchannel(char* param)
248{
249        char* buf = NULL, *tmpstr = NULL, *tmpstr1 = NULL;
250        struct mainbouquet *mbouquet = NULL;
251        struct bouquet *node = NULL;
252        struct channel* chnode = NULL;
253        int line = 0, maxlen = 0, pos = 0;
254
255        if(param == NULL) return NULL;
256
257        webcreateheadbig(&buf, &maxlen, "<meta http-equiv=refresh content=15>", &pos, 0);
258
259        mbouquet = getmainbouquet(param);
260        if(mbouquet != NULL)
261        {
262                node = mbouquet->bouquet;
263                tmpstr = ostrcat(tmpstr, "(BOUQUET)-", 1, 0);
264                tmpstr = ostrcat(tmpstr, mbouquet->name, 1, 0);
265                tmpstr1 = htmlencode(tmpstr);
266                free(tmpstr); tmpstr = NULL;
267                while(node != NULL)
268                {
269                        chnode = getchannel(node->serviceid, node->transponderid);
270                        if(chnode != NULL)
271                        {
272                                webcreatechannelbody(&buf, line, chnode, tmpstr1, &maxlen, &pos, 0);
273                                if(line == 0)
274                                        line = 1;
275                                else
276                                        line = 0;
277                        }
278                        node = node->next;
279                }
280                free(tmpstr1); tmpstr1 = NULL;
281        }
282        webcreatetailbig(&buf, &maxlen, &pos, 0);
283
284        return buf;
285}
286
287//flag 0: all
288//flag 1: sat
289//flag 2: provider
290//flag 3: A-Z
291char* webgetchannel(int param, int flag, int page)
292{
293        char* buf = NULL, *tmpnr = NULL, *tmpstr = NULL, *tmpstr1 = NULL;
294        struct channel* chnode = channel;
295        int line = 0, maxcount = 0, maxlen = 0, pos = 0;
296
297        webcreateheadbig(&buf, &maxlen, "<meta http-equiv=refresh content=15>", &pos, 0);
298
299        if(flag == 0) tmpstr1 = ostrcat(tmpstr1, "(ALL)", 1, 0);
300        if(flag == 1)
301        {
302                struct sat* node = getsatbyorbitalpos(param);
303                if(node != NULL)
304                {
305                        tmpstr = ostrcat(tmpstr, "(SAT)-", 1, 0);
306                        tmpstr = ostrcat(tmpstr, node->name, 1, 0);
307                        tmpstr1 = htmlencode(tmpstr);
308                        free(tmpstr); tmpstr = NULL;
309                }
310        }
311        if(flag == 2)
312        {
313                struct provider* node = getprovider(param);
314                if(node != NULL)
315                {
316                        tmpstr = ostrcat(tmpstr, "(PROVIDER)-", 1, 0);
317                        tmpstr = ostrcat(tmpstr, node->name, 1, 0);
318                        tmpstr1 = htmlencode(tmpstr);
319                        free(tmpstr); tmpstr = NULL;
320                }
321        }
322        if(flag == 3)
323        {
324                tmpstr = malloc(2);
325                if(tmpstr != NULL)
326                        snprintf(tmpstr, 2, "%c", param);
327                tmpstr = ostrcat("(A-Z)-", tmpstr, 0, 1);
328                tmpstr1 = htmlencode(tmpstr);
329                free(tmpstr); tmpstr = NULL;
330        }
331
332        while(chnode != NULL)
333        {
334                if(chnode->transponder == NULL)
335                {
336                        chnode = chnode->next;
337                        continue;
338                }
339                if(chnode->name == NULL)
340                {
341                        chnode = chnode->next;
342                        continue;
343                }
344                if(flag == 1 && chnode->transponder->orbitalpos != param)
345                {
346                        chnode = chnode->next;
347                        continue;
348                }
349                if(flag == 2 && chnode->providerid != param)
350                {
351                        chnode = chnode->next;
352                        continue;
353                }
354                if(flag == 3 && chnode->name[0] != param && chnode->name[0] != param + 32)
355                {
356                        chnode = chnode->next;
357                        continue;
358                }
359
360                maxcount++;
361                if(maxcount <= (MAXHTMLLINE * page) - MAXHTMLLINE || maxcount > MAXHTMLLINE * page)
362                {
363                        chnode = chnode->next;
364                        continue;
365                }
366                webcreatechannelbody(&buf, line, chnode, tmpstr1, &maxlen, &pos, 0);
367
368                if(line == 0)
369                        line = 1;
370                else
371                        line = 0;
372
373                chnode = chnode->next;
374        }
375        free(tmpstr); tmpstr = NULL;
376
377        if(maxcount > MAXHTMLLINE)
378        {
379                int i;
380                ostrcatbig(&buf, "<tr><td align=center><br>", &maxlen, &pos);
381                for(i = 1; i <= (int)ceil(((float)maxcount / MAXHTMLLINE)); i++)
382                {
383                        if(page == i)
384                                ostrcatbig(&buf, "<a class=pagesellink href=query?getchannelpage&", &maxlen, &pos);
385                        else
386                                ostrcatbig(&buf, "<a class=pagelink href=query?getchannelpage&", &maxlen, &pos);
387                        tmpnr = oitoa(param);
388                        ostrcatbig(&buf, tmpnr, &maxlen, &pos);
389                        ostrcatbig(&buf, "&", &maxlen, &pos);
390                        free(tmpnr); tmpnr = NULL;
391                        tmpnr = oitoa(flag);
392                        ostrcatbig(&buf, tmpnr, &maxlen, &pos);
393                        ostrcatbig(&buf, "&", &maxlen, &pos);
394                        free(tmpnr); tmpnr = NULL;
395
396                        tmpnr = oitoa(i);
397                        ostrcatbig(&buf, tmpnr, &maxlen, &pos);
398                        ostrcatbig(&buf, ">", &maxlen, &pos);
399                        ostrcatbig(&buf, tmpnr, &maxlen, &pos);
400                        ostrcatbig(&buf, "</a>", &maxlen, &pos);
401                        free(tmpnr); tmpnr = NULL;
402                }
403                ostrcatbig(&buf, "</td></tr>", &maxlen, &pos);
404        }
405
406        webcreatetailbig(&buf, &maxlen, &pos, 0);
407        return buf;
408}
409
410char* webgetprovider()
411{
412        char* buf = NULL, *tmpstr = NULL;
413        struct provider* node = provider;
414        int line = 0, maxlen = 0, pos = 0;
415
416        webcreateheadbig(&buf, &maxlen, NULL, &pos, 0);
417
418        while(node != NULL)
419        {
420                if(line == 0)
421                {
422                        ostrcatbig(&buf, "<tr class=line1><td nowrap><a class=link href=\"query?getproviderchannel&", &maxlen, &pos);
423                        tmpstr = oitoa(node->providerid);
424                        ostrcatbig(&buf, tmpstr, &maxlen, &pos);
425                        free(tmpstr); tmpstr = NULL;
426                        ostrcatbig(&buf, "\">", &maxlen, &pos);
427                        line = 1;
428                }
429                else
430                {
431                        ostrcatbig(&buf, "<tr class=line2><td nowrap><a class=link href=\"query?getproviderchannel&", &maxlen, &pos);
432                        tmpstr = oitoa(node->providerid);
433                        ostrcatbig(&buf, tmpstr, &maxlen, &pos);
434                        free(tmpstr); tmpstr = NULL;
435                        ostrcatbig(&buf, "\">", &maxlen, &pos);
436                        line = 0;
437                }
438                ostrcatbig(&buf, node->name, &maxlen, &pos);
439                ostrcatbig(&buf, "</td></tr>", &maxlen, &pos);
440
441                node = node->next;
442        }
443
444        webcreatetailbig(&buf, &maxlen, &pos, 0);
445        return buf;
446}
447
448char* webgetsat()
449{
450        char* buf = NULL, *tmpstr = NULL;
451        struct sat* node = sat;
452        int line = 0, maxlen = 0, pos = 0;
453
454        webcreateheadbig(&buf, &maxlen, NULL, &pos, 0);
455
456        while(node != NULL)
457        {
458                if(line == 0)
459                {
460                        ostrcatbig(&buf, "<tr class=line1><td nowrap><a class=link href=\"query?getsatchannel&", &maxlen, &pos);
461                        tmpstr = oitoa(node->orbitalpos);
462                        ostrcatbig(&buf, tmpstr, &maxlen, &pos);
463                        free(tmpstr); tmpstr = NULL;
464                        ostrcatbig(&buf, "\">", &maxlen, &pos);
465                        line = 1;
466                }
467                else
468                {
469                        ostrcatbig(&buf, "<tr class=line2><td nowrap><a class=link href=\"query?getsatchannel&", &maxlen, &pos);
470                        tmpstr = oitoa(node->orbitalpos);
471                        ostrcatbig(&buf, tmpstr, &maxlen, &pos);
472                        free(tmpstr); tmpstr = NULL;
473                        ostrcatbig(&buf, "\">", &maxlen, &pos);
474                        line = 0;
475                }
476                ostrcatbig(&buf, node->name, &maxlen, &pos);
477                ostrcatbig(&buf, "</td></tr>", &maxlen, &pos);
478
479                node = node->next;
480        }
481
482        webcreatetailbig(&buf, &maxlen, &pos, 0);
483        return buf;
484}
485
486char* webgetaz()
487{
488        char* buf = NULL, *tmpstr = NULL, *tmpnr = NULL;
489        int line = 0, maxlen = 0, pos = 0, i;
490
491        tmpstr = malloc(2);
492        if(tmpstr == NULL)
493        {
494                err("no memory");
495                return NULL;
496        }
497
498        webcreateheadbig(&buf, &maxlen, NULL, &pos, 0);
499
500        for(i = 65; i < 91; i++)
501        {
502                if(line == 0)
503                {
504                        ostrcatbig(&buf, "<tr class=line1><td nowrap><a class=link href=\"query?getazchannel&", &maxlen, &pos);
505                        tmpnr = oitoa(i);
506                        ostrcatbig(&buf, tmpnr, &maxlen, &pos);
507                        free(tmpnr); tmpnr = NULL;
508                        ostrcatbig(&buf, "\">", &maxlen, &pos);
509                        line = 1;
510                }
511                else
512                {
513                        ostrcatbig(&buf, "<tr class=line2><td nowrap><a class=link href=\"query?getazchannel&", &maxlen, &pos);
514                        tmpnr = oitoa(i);
515                        ostrcatbig(&buf, tmpnr, &maxlen, &pos);
516                        free(tmpnr); tmpnr = NULL;
517                        ostrcatbig(&buf, "\">", &maxlen, &pos);
518                        line = 0;
519                }
520                snprintf(tmpstr, 2, "%c", i);
521                ostrcatbig(&buf, tmpstr, &maxlen, &pos);
522                ostrcatbig(&buf, "</td></tr>", &maxlen, &pos);
523        }
524
525        webcreatetailbig(&buf, &maxlen, &pos, 0);
526        free(tmpstr);
527        return buf;
528}
529
530char* webgetbouquet()
531{
532        char* buf = NULL;
533        struct mainbouquet* node = mainbouquet;
534        int line = 0, maxlen = 0, pos = 0;
535
536        webcreateheadbig(&buf, &maxlen, NULL, &pos, 0);
537
538        while(node != NULL)
539        {
540                if(line == 0)
541                {
542                        ostrcatbig(&buf, "<tr class=line1><td width=100% nowrap><a class=link href=\"query?getbouquetchannel&", &maxlen, &pos);
543                        ostrcatbig(&buf, node->name, &maxlen, &pos);
544                        ostrcatbig(&buf, "\">", &maxlen, &pos);
545                        line = 1;
546                }
547                else
548                {
549                        ostrcatbig(&buf, "<tr class=line2><td width=100% nowrap><a class=link href=\"query?getbouquetchannel&", &maxlen, &pos);
550                        ostrcatbig(&buf, node->name, &maxlen, &pos);
551                        ostrcatbig(&buf, "\">", &maxlen, &pos);
552                        line = 0;
553                }
554                ostrcatbig(&buf, node->name, &maxlen, &pos);
555                ostrcatbig(&buf, "</a></td>", &maxlen, &pos);
556
557                ostrcatbig(&buf, "<td width=50 nowrap align=right valign=middle><img style=\"margin-left: 5\" border=0 src=", &maxlen, &pos);
558
559                if(node->type == 0)
560                        ostrcatbig(&buf, "img/tv.png width=16 height=16 alt=TV>", &maxlen, &pos);
561                else
562                        ostrcatbig(&buf, "img/radio.png width=16 height=16 alt=Radio>", &maxlen, &pos);
563                ostrcatbig(&buf, "<a href=\"query?getgmultiepg&", &maxlen, &pos);
564                ostrcatbig(&buf, node->name, &maxlen, &pos);
565                ostrcatbig(&buf, "\">", &maxlen, &pos);
566                ostrcatbig(&buf, "<img style=\"margin-left: 5\" border=0 width=16 height=16 alt=\"Graphical Multi EPG\" src=img/gmultiepg.png></a>", &maxlen, &pos);
567                ostrcatbig(&buf, "</td></tr>", &maxlen, &pos);
568
569                node = node->next;
570        }
571
572        webcreatetailbig(&buf, &maxlen, &pos, 0);
573        return buf;
574}
575
576char* websetmute(char* param)
577{
578        char* buf = NULL;
579        int mute = status.mute;
580
581        if(param != NULL)
582                mute = atoi(param);
583
584        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);
585        if(mute == 0)
586                buf = ostrcat(buf, "<a href=query?setmute&1><img src=img/speak_on.png border=0 alt=\"Mute on\"></img></a>", 1, 0);
587        else
588                buf = ostrcat(buf, "<a href=query?setmute&0><img src=img/speak_off.png border=0 alt=\"Mute off\"></img></a>", 1, 0);
589        buf = ostrcat(buf, "</center></body></html>", 1, 0);
590
591        if(mute != status.mute)
592                screenmute(NULL, NULL, 0);
593       
594        return buf;
595}
596
597char* websetvol(char* param)
598{
599        char* buf = NULL;
600        int vol = 30;
601
602        if(param == NULL)
603                vol = getvol();
604        else
605                vol = atoi(param);
606
607        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);
608        if(vol >=10)
609                buf = ostrcat(buf, "<a href=query?setvol&10><img src=img/led_on.png border=0></img></a> ", 1, 0);
610        else
611                buf = ostrcat(buf, "<a href=query?setvol&10><img src=img/led_off.png border=0></img></a> ", 1, 0);
612        if(vol >=20)
613                buf = ostrcat(buf, "<a href=query?setvol&20><img src=img/led_on.png border=0></img></a> ", 1, 0);
614        else
615                buf = ostrcat(buf, "<a href=query?setvol&20><img src=img/led_off.png border=0></img></a> ", 1, 0);
616        if(vol >=30)
617                buf = ostrcat(buf, "<a href=query?setvol&30><img src=img/led_on.png border=0></img></a> ", 1, 0);
618        else
619                buf = ostrcat(buf, "<a href=query?setvol&30><img src=img/led_off.png border=0></img></a> ", 1, 0);
620        if(vol >=40)
621                buf = ostrcat(buf, "<a href=query?setvol&40><img src=img/led_on.png border=0></img></a> ", 1, 0);
622        else
623                buf = ostrcat(buf, "<a href=query?setvol&40><img src=img/led_off.png border=0></img></a> ", 1, 0);
624        if(vol >=50)
625                buf = ostrcat(buf, "<a href=query?setvol&50><img src=img/led_on.png border=0></img></a> ", 1, 0);
626        else
627                buf = ostrcat(buf, "<a href=query?setvol&50><img src=img/led_off.png border=0></img></a> ", 1, 0);
628        if(vol >=60)
629                buf = ostrcat(buf, "<a href=query?setvol&60><img src=img/led_on.png border=0></img></a> ", 1, 0);
630        else
631                buf = ostrcat(buf, "<a href=query?setvol&60><img src=img/led_off.png border=0></img></a> ", 1, 0);
632        if(vol >=70)
633                buf = ostrcat(buf, "<a href=query?setvol&70><img src=img/led_on.png border=0></img></a> ", 1, 0);
634        else
635                buf = ostrcat(buf, "<a href=query?setvol&70><img src=img/led_off.png border=0></img></a> ", 1, 0);
636        if(vol >=80)
637                buf = ostrcat(buf, "<a href=query?setvol&80><img src=img/led_on.png border=0></img></a> ", 1, 0);
638        else
639                buf = ostrcat(buf, "<a href=query?setvol&80><img src=img/led_off.png border=0></img></a> ", 1, 0);
640        if(vol >=90)
641                buf = ostrcat(buf, "<a href=query?setvol&90><img src=img/led_on.png border=0></img></a> ", 1, 0);
642        else
643                buf = ostrcat(buf, "<a href=query?setvol&90><img src=img/led_off.png border=0></img></a> ", 1, 0);
644        if(vol >=100)
645                buf = ostrcat(buf, "<a href=query?setvol&100><img src=img/led_on.png border=0></img></a> ", 1, 0);
646        else
647                buf = ostrcat(buf, "<a href=query?setvol&100><img src=img/led_off.png border=0></img></a> ", 1, 0);
648        buf = ostrcat(buf, "</center></body></html>", 1, 0);
649
650        if(param != NULL)
651        {
652                setvol(vol);
653                if(status.mute == 1)
654                        screenmute(NULL, NULL, 0);
655        }
656        return buf;
657}
658
659char* webgetaktservice()
660{
661        char* buf = NULL;
662        struct channel* chnode = status.aktservice->channel;
663        int line = 0, maxlen = 0, pos = 0;
664
665        webcreateheadbig(&buf, &maxlen, NULL, &pos, 1);
666        webcreatechannelbody(&buf, line, chnode, getconfig("channellist", NULL), &maxlen, &pos ,1);
667        webcreatetailbig(&buf, &maxlen, &pos, 1);
668
669        return buf;
670}
671
672char* webswitch(char* param)
673{
674        if(status.channelswitch == 1) goto end;
675
676        int ret = 0;
677        char* param1 = NULL, *param2 = NULL;
678        struct channel* chnode = NULL;
679
680        if(param == NULL) goto end;
681
682        //create param1
683        param1 = strchr(param, '&');
684        if(param1 != NULL)
685        {
686                *param1++ = '\0';
687                param2 = strchr(param1, '&');
688                if(param2 != NULL)
689                        *param2++ = '\0';
690        }
691
692        if(param1 == NULL && param2 == NULL) goto end;
693
694        chnode = getchannel(atoi(param), atoi(param1));
695        if(chnode != NULL)
696        {
697                ret = channelnottunable(chnode);
698                if(ret == 0)
699                        ret = servicestart(chnode, param2, NULL, 0);
700        }
701
702end:
703        return webgetaktservice();
704}
705
706char* webgetm3u(char* param, int connfd)
707{
708        char* buf = NULL, *ip = NULL, *tmpbuf = NULL;
709        struct sockaddr_in sin;
710        socklen_t len = sizeof(sin);
711
712        if(param == NULL) return NULL;
713
714        if(getsockname(connfd, &sin, &len) < 0)
715        {
716                perr("getsockname");
717                return NULL;
718        }
719
720        ip = inet_ntoa(sin.sin_addr);
721        if(ip == NULL) return NULL;
722
723        buf = ostrcat(buf, "#EXTM3U\n", 1, 0);
724        buf = ostrcat(buf, "#EXTVLCOPT--http-reconnect=true\n", 1, 0);
725        buf = ostrcat(buf, "http://", 1, 0);
726        buf = ostrcat(buf, ip, 1, 0);
727        buf = ostrcat(buf, ":", 1, 0);
728        buf = ostrcat(buf, getconfig("streamport", NULL), 1, 0);
729        buf = ostrcat(buf, "/", 1, 0);
730
731        tmpbuf = htmlencode(param);
732        if(tmpbuf != NULL)
733                param = tmpbuf;
734
735        buf = ostrcat(buf, param, 1, 0);
736        free(tmpbuf); tmpbuf = NULL;
737
738        return buf;
739}
740
741char* webgetvideo(char* param, int connfd)
742{
743        char* buf = NULL, *ip = NULL, *tmpbuf = NULL;
744        struct sockaddr_in sin;
745        socklen_t len = sizeof(sin);
746
747        if(param == NULL) return NULL;
748
749        if(getsockname(connfd, &sin, &len) < 0)
750        {
751                perr("getsockname");
752                return NULL;
753        }
754
755        ip = inet_ntoa(sin.sin_addr);
756        if(ip == NULL) return NULL;
757
758        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);
759        buf = ostrcat(buf, "<embed width=100% height=100% type=application/x-vlc-plugin name=video autoplay=yes target=\"http://", 1, 0);
760        buf = ostrcat(buf, ip, 1, 0);
761        buf = ostrcat(buf, ":", 1, 0);
762        buf = ostrcat(buf, getconfig("streamport", NULL), 1, 0);
763        buf = ostrcat(buf, "/", 1, 0);
764
765        tmpbuf = htmlencode(param);
766        if(tmpbuf != NULL)
767                param = tmpbuf;
768
769        buf = ostrcat(buf, param, 1, 0);
770        free(tmpbuf); tmpbuf = NULL;
771        buf = ostrcat(buf, "\" />", 1, 0);
772        //buf = ostrcat(buf, "<a href=javascript:; onclick='document.video.play()'>Play</a>", 1, 0);
773        //buf = ostrcat(buf, "<a href=javascript:; onclick='document.video.stop()'>Stop</a>", 1, 0);
774        //buf = ostrcat(buf, "<a href=javascript:; onclick='document.video.fullscreen()'>Fullscreen</a>", 1, 0);
775        buf = ostrcat(buf, "</td></tr></body></html>", 1, 0);
776
777        return buf;
778}
779
780char* webgetchannelpage(char* param)
781{
782        char* param1 = NULL, *param2 = NULL;
783
784        if(param == NULL) return NULL;
785
786        //create param1 + 2
787        param1 = strchr(param, '&');
788        if(param1 != NULL)
789        {
790                *param1++ = '\0';
791                param2 = strchr(param1, '&');
792                if(param2 != NULL)
793                        *param2++ = '\0';
794        }
795
796        if(param1 == NULL || param2 == NULL) return NULL;
797
798        return webgetchannel(atoi(param), atoi(param1), atoi(param2));
799}
800
801void webmessage(struct stimerthread* timernode, char* text, int flag)
802{
803        textbox(_("Message"), text, _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
804        free(text);
805}
806
807char* websendmessage(char* param)
808{
809        char* text = NULL, *buf = NULL;
810
811        if(param == NULL) return NULL;
812        param = strchr(param, '=');
813        if(param != NULL)
814        {
815                param++;
816                stringreplacechar(param, '+', ' ');
817                text = ostrcat(text, param, 1, 0);
818        }
819        addtimer(&webmessage, START, 1000, 1, (void*)text, NULL, NULL);
820
821        buf = webcreatehead(buf, NULL, 1);
822        buf = ostrcat(buf, "<tr><td align=center valign=top><font class=biglabel><br><br>Message Send !!!</font></td></tr>", 1, 0);
823        buf = webcreatetail(buf, 1);
824
825        return buf;
826}
827
828char* webgetsignal()
829{
830        char* buf = NULL, *tmpnr = NULL;
831        uint16_t snr = 0, signal = 0;
832        uint32_t ber = 0, unc = 0;
833
834        ber = fereadber(status.aktservice->fedev);
835        unc = fereaduncorrectedblocks(status.aktservice->fedev);
836        signal = fereadsignalstrength(status.aktservice->fedev);
837        snr = fereadsnr(status.aktservice->fedev);
838        snr = (snr * 100) / 0xffff;
839
840        buf = webcreatehead(buf, "<meta http-equiv=refresh content=1>", 0);
841
842        buf = ostrcat(buf, "<tr><td align=center><font class=biglabel><br><br>BER: ", 1, 0);
843        tmpnr = oitoa(ber);
844        buf = ostrcat(buf, tmpnr, 1, 0);
845        free(tmpnr); tmpnr = NULL;
846
847        buf = ostrcat(buf, "<br>UNC: ", 1, 0);
848        tmpnr = oitoa(unc);
849        buf = ostrcat(buf, tmpnr, 1, 0);
850        free(tmpnr); tmpnr = NULL;
851
852        buf = ostrcat(buf, "<br>SIG: ", 1, 0);
853        tmpnr = oitoa(signal);
854        buf = ostrcat(buf, tmpnr, 1, 0);
855        free(tmpnr); tmpnr = NULL;
856
857        buf = ostrcat(buf, "<br>SNR: ", 1, 0);
858        tmpnr = oitoa(snr);
859        buf = ostrcat(buf, tmpnr, 1, 0);
860        free(tmpnr); tmpnr = NULL;
861
862        buf = ostrcat(buf, "</font></td></tr>", 1, 0);
863        buf = webcreatetail(buf, 0);
864        return buf;
865}
866
867char* webgetepg(char* param)
868{
869        char* buf = NULL, *buf1 = NULL, *tmpstr = NULL, *param1 = NULL, *param2 = NULL;
870        struct epg* epgnode = NULL;
871        struct channel* chnode = NULL;
872        struct tm *loctime = NULL;
873
874        if(param == NULL) return NULL;
875
876        //create param1 + 2
877        param1 = strchr(param, '&');
878        if(param1 != NULL)
879        {
880                *param1++ = '\0';
881                param2 = strchr(param1, '&');
882                if(param2 != NULL)
883                        *param2++ = '\0';
884        }
885
886        if(param1 == NULL || param2 == NULL) return NULL;
887
888        chnode = getchannel(atoi(param), atoi(param1));
889        if(chnode == NULL) return NULL;
890
891        epgnode = getepg(chnode, atoi(param2), 0);
892        if(epgnode == NULL) return NULL;
893
894        buf = webcreatehead(buf, NULL, 0);
895
896        buf1 = malloc(MINMALLOC);
897        if(buf1 == NULL)
898        {
899                err("no mem");
900                return buf;
901        }
902
903        buf = ostrcat(buf, "<tr><td><font class=biglabel>", 1, 0);
904        if(epgnode->title != NULL)
905        {
906                buf = ostrcat(buf, epgnode->title, 1, 0);
907                buf = ostrcat(buf, " (", 1, 0);
908                loctime = olocaltime(&epgnode->starttime);
909                if(loctime != NULL)
910                        strftime(buf1, MINMALLOC, "%H:%M -", loctime);
911                free(loctime); loctime = NULL;
912                loctime = olocaltime(&epgnode->endtime);
913                if(loctime != NULL)
914                        strftime(&buf1[7], MINMALLOC - 8, " %H:%M", loctime);
915                free(loctime); loctime = NULL;
916                buf = ostrcat(buf, buf1, 1, 0);
917                buf = ostrcat(buf, ")", 1, 0);
918        }
919        buf = ostrcat(buf, "<br><br></font></td></tr>", 1, 0);
920
921        buf = ostrcat(buf, "<tr><td><font class=label>", 1, 0);
922        if(epgnode->subtitle != NULL)
923                buf = ostrcat(buf, epgnode->subtitle, 1, 0);
924        buf = ostrcat(buf, "<br><br></font></td></tr>", 1, 0);
925
926        buf = ostrcat(buf, "<tr><td><font class=label>", 1, 0);
927        tmpstr = epgdescunzip(epgnode);
928        if(tmpstr != NULL)
929                buf = ostrcat(buf, tmpstr, 1, 0);
930        free(tmpstr); tmpstr = NULL;
931        buf = ostrcat(buf, "</font></td></tr>", 1, 0);
932
933        buf = webcreatetail(buf, 0);
934
935        free(buf1);
936        return buf;
937}
938
939char* webgetsingleepg(char* param)
940{
941        int line = 0, maxlen = 0, pos = 0;
942        char* buf = NULL, *buf1 = NULL, *buf2 = NULL, *param1 = NULL, *tmpstr = NULL;
943        struct epg* epgnode = NULL;
944        struct channel* chnode = NULL;
945        struct tm *loctime = NULL;
946
947        //create param1
948        param1 = strchr(param, '&');
949        if(param1 != NULL)
950                *param1++ = '\0';
951
952        if(param1 == NULL) return NULL;
953
954        chnode = getchannel(atoi(param), atoi(param1));
955        if(chnode == NULL) return NULL;
956        epgnode = getepgakt(chnode);;
957
958        webcreateheadbig(&buf, &maxlen, NULL, &pos, 0);
959
960        buf1 = malloc(MINMALLOC);
961        if(buf1 == NULL)
962        {
963                err("no mem");
964                return buf;
965        }
966
967        while(epgnode != NULL)
968        {
969                if(line == 0)
970                {
971                        ostrcatbig(&buf, "<tr class=line1>", &maxlen, &pos);
972                        line = 1;
973                }
974                else
975                {
976                        ostrcatbig(&buf, "<tr class=line2>", &maxlen, &pos);
977                        line = 0;
978                }
979
980
981                ostrcatbig(&buf, "<td nowrap><a target=main class=link href=query?getepg&", &maxlen, &pos);
982                tmpstr = oitoa(chnode->serviceid);
983                ostrcatbig(&buf, tmpstr, &maxlen, &pos);
984                buf2 = ostrcat("<td nowrap><a target=main class=link href=query?addrectimer&",tmpstr, 0, 0);
985                buf2 = ostrcat(buf2, "&", 0, 0);
986                free(tmpstr); tmpstr = NULL;
987                ostrcatbig(&buf, "&", &maxlen, &pos);
988                tmpstr = olutoa(chnode->transponderid);
989                ostrcatbig(&buf, tmpstr, &maxlen, &pos);
990                buf2 = ostrcat(buf2, tmpstr, 0, 0);
991                buf2 = ostrcat(buf2, "&", 0, 0);
992                free(tmpstr); tmpstr = NULL;
993                ostrcatbig(&buf, "&", &maxlen, &pos);
994                tmpstr = oitoa(epgnode->eventid);
995                ostrcatbig(&buf, tmpstr, &maxlen, &pos);
996                buf2 = ostrcat(buf2, tmpstr, 0, 0);
997                buf2 = ostrcat(buf2, ">", 0, 0);
998                free(tmpstr); tmpstr = NULL;
999                ostrcatbig(&buf, ">", &maxlen, &pos);
1000
1001                loctime = olocaltime(&epgnode->starttime);
1002                if(loctime != NULL)
1003                        strftime(buf1, MINMALLOC, "%d.%m _ %H:%M __ ", loctime);
1004                        //strftime(buf1, MINMALLOC, "%H:%M -", loctime);
1005                free(loctime); loctime = NULL;
1006                //loctime = olocaltime(&epgnode->endtime);
1007                //if(loctime != NULL)
1008                //      strftime(&buf1[7], MINMALLOC - 8, " %H:%M ", loctime);
1009                //free(loctime); loctime = NULL;
1010                ostrcatbig(&buf, buf1, &maxlen, &pos);
1011                ostrcatbig(&buf, " ", &maxlen, &pos);
1012                ostrcatbig(&buf, epgnode->title, &maxlen, &pos);
1013                if(epgnode->subtitle != NULL)
1014                {
1015                        ostrcatbig(&buf, " (", &maxlen, &pos);
1016                        ostrcatbig(&buf, epgnode->subtitle, &maxlen, &pos);
1017                        ostrcatbig(&buf, ")", &maxlen, &pos);
1018                }
1019                ostrcatbig(&buf, "</a></td>", &maxlen, &pos);
1020                ostrcatbig(&buf, buf2, &maxlen, &pos);
1021                ostrcatbig(&buf, "<img border=0 width=16 height=16 src=img/timer.png alt=\"set timer\"/>", &maxlen, &pos);
1022                ostrcatbig(&buf, "</a></td></tr>", &maxlen, &pos);
1023       
1024                epgnode = epgnode->next;
1025                free(buf2); buf2 = NULL;
1026        }
1027
1028        webcreatetailbig(&buf, &maxlen, &pos, 0);
1029
1030        free(buf1);
1031        return buf;
1032}
1033
1034//TODO: create rectimer line
1035void webcalcrecline(char** buf, int* maxlen, int* pos)
1036{
1037        //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);
1038}
1039
1040char* webgetgmultiepg(char* param)
1041{
1042        int page = 1, i, line = 0, treffer = 0, maxlen = 0, pos = 0;
1043        char* buf = NULL, *tmpnr = NULL, *param1 = NULL;
1044        struct mainbouquet *mbouquet = NULL;
1045        struct bouquet *node = NULL;
1046        struct channel* chnode = NULL;
1047        struct epg* epgnode = NULL;
1048        time_t akttime = 0, difftime = 0, starttime = 0, endtime = 0, lastendtime = 0;
1049
1050        if(param == NULL) return NULL;
1051
1052        //create param1
1053        param1 = strchr(param, '&');
1054        if(param1 != NULL)
1055                *param1++ = '\0';
1056
1057        if(param1 != NULL) page = atoi(param1);
1058
1059        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);
1060
1061        akttime = webcreatetimeline(&buf, &maxlen, &pos);
1062        akttime += ((page - 1) * 1440);
1063        ostrcatbig(&buf, "</tr></thead><tbody>", &maxlen, &pos);
1064
1065        mbouquet = getmainbouquet(param);
1066        if(mbouquet != NULL)
1067        {
1068                node = mbouquet->bouquet;
1069                while(node != NULL)
1070                {
1071                        chnode = getchannel(node->serviceid, node->transponderid);
1072                        if(chnode != NULL)
1073                        {
1074                                if(line == 0)
1075                                {
1076                                        ostrcatbig(&buf, "<tr><th class=gepgchannel1>", &maxlen, &pos);
1077                                        ostrcatbig(&buf, chnode->name, &maxlen, &pos);
1078                                        ostrcatbig(&buf, "</th><td class=gepgchannelcell colspan=1000>", &maxlen, &pos);
1079                                        webcalcrecline(&buf, &maxlen, &pos);
1080                                        ostrcatbig(&buf, "<table border=0 cellpadding=0 cellspacing=0 style=\"table-layout: fixed;\"><tr class=line1>", &maxlen, &pos);
1081                                        line = 1;
1082                                }
1083                                else
1084                                {
1085                                        ostrcatbig(&buf, "<tr><th class=gepgchannel2>", &maxlen, &pos);
1086                                        ostrcatbig(&buf, chnode->name, &maxlen, &pos);
1087                                        ostrcatbig(&buf, "</th><td class=gepgchannelcell colspan=1000>", &maxlen, &pos);
1088                                        webcalcrecline(&buf, &maxlen, &pos);
1089
1090                                        ostrcatbig(&buf, "<table border=0 cellpadding=0 cellspacing=0 style=\"table-layout: fixed;\"><tr class=line2>", &maxlen, &pos);
1091                                        line = 0;
1092                                }
1093
1094                                treffer = 0;
1095                                lastendtime = 0;
1096                                epgnode = getepgakt(chnode);
1097                                while(epgnode != NULL)
1098                                {
1099                                        treffer = 1;
1100                                        starttime = epgnode->starttime / 60;
1101                                        endtime = epgnode->endtime / 60;
1102
1103                                        if(endtime <= starttime || starttime >= akttime + 1440)
1104                                        {
1105                                                epgnode = epgnode->next;
1106                                                continue;
1107                                        }
1108
1109                                        //check if old endtime > new starttime
1110                                        if(lastendtime > 0 && starttime > lastendtime)
1111                                        {
1112                                                difftime = (starttime - lastendtime) * 5;
1113
1114                                                if(difftime <= 0)
1115                                                {
1116                                                        epgnode = epgnode->next;
1117                                                        continue;
1118                                                }
1119
1120                                                ostrcatbig(&buf, "<td class=gepgcellblank style=\"", &maxlen, &pos);
1121                                                tmpnr = oitoa(difftime);
1122                                                ostrcatbig(&buf, "width:", &maxlen, &pos);
1123                                                ostrcatbig(&buf, tmpnr, &maxlen, &pos);
1124                                                ostrcatbig(&buf, "px;", &maxlen, &pos);
1125                                                ostrcatbig(&buf, "min-width:", &maxlen, &pos);
1126                                                ostrcatbig(&buf, tmpnr, &maxlen, &pos);
1127                                                ostrcatbig(&buf, "px;", &maxlen, &pos);
1128                                                ostrcatbig(&buf, "max-width:", &maxlen, &pos);
1129                                                ostrcatbig(&buf, tmpnr, &maxlen, &pos);
1130                                                ostrcatbig(&buf, "px;", &maxlen, &pos);
1131                                                free(tmpnr); tmpnr = NULL;
1132
1133                                                ostrcatbig(&buf, "\"> </td>", &maxlen, &pos);
1134                                        }
1135
1136                                        //check if starttime < last endtime
1137                                        if(starttime < lastendtime)
1138                                                starttime = lastendtime;
1139
1140                                        //check if endtime is in next day
1141                                        if(endtime > akttime + 1440)
1142                                                endtime = endtime - (endtime - (akttime + 1440));
1143
1144                                        //check if starttime is in prev day
1145                                        if(starttime < akttime)
1146                                                difftime = (endtime - akttime) * 5;
1147                                        else
1148                                                difftime = (endtime - starttime) * 5;
1149
1150                                        if(difftime <= 0)
1151                                        {
1152                                                epgnode = epgnode->next;
1153                                                continue;
1154                                        }
1155
1156                                        lastendtime = endtime;
1157
1158                                        ostrcatbig(&buf, "<td class=gepgcell style=\"", &maxlen, &pos);
1159                                        tmpnr = oitoa(difftime);
1160                                        ostrcatbig(&buf, "width:", &maxlen, &pos);
1161                                        ostrcatbig(&buf, tmpnr, &maxlen, &pos);
1162                                        ostrcatbig(&buf, "px;", &maxlen, &pos);
1163                                        ostrcatbig(&buf, "min-width:", &maxlen, &pos);
1164                                        ostrcatbig(&buf, tmpnr, &maxlen, &pos);
1165                                        ostrcatbig(&buf, "px;", &maxlen, &pos);
1166                                        ostrcatbig(&buf, "max-width:", &maxlen, &pos);
1167                                        ostrcatbig(&buf, tmpnr, &maxlen, &pos);
1168                                        ostrcatbig(&buf, "px;", &maxlen, &pos);
1169                                        free(tmpnr); tmpnr = NULL;
1170
1171                                        ostrcatbig(&buf, "\"><div class=gepgcellborder>", &maxlen, &pos);
1172                                        ostrcatbig(&buf, epgnode->title, &maxlen, &pos);
1173                                        ostrcatbig(&buf, "</div></div></td>", &maxlen, &pos);
1174                                       
1175                                        epgnode = epgnode->next;
1176                                }
1177                                if(treffer == 0)
1178                                        ostrcatbig(&buf, "<td class=gepgcellblank> </td>", &maxlen, &pos);
1179                        }
1180                        ostrcatbig(&buf, "</tr></table></td></tr>", &maxlen, &pos);
1181
1182                        node = node->next;
1183                }
1184        }
1185        ostrcatbig(&buf, "<script type=text/javascript>if(typeof tableScroll == 'function'){tableScroll('gmultiepg');}</script></tbody></table></td></tr><tr><td align=center>", &maxlen, &pos);
1186
1187        for(i = 1; i <= 14; i++)
1188        {
1189                if(page == i)
1190                        ostrcatbig(&buf, "<a class=pagesellink href=\"query?getgmultiepg&", &maxlen, &pos);
1191                else
1192                        ostrcatbig(&buf, "<a class=pagelink href=\"query?getgmultiepg&", &maxlen, &pos);
1193                ostrcatbig(&buf, param, &maxlen, &pos);
1194                ostrcatbig(&buf, "&", &maxlen, &pos);
1195                tmpnr = oitoa(i);
1196                ostrcatbig(&buf, tmpnr, &maxlen, &pos);
1197                ostrcatbig(&buf, "\">", &maxlen, &pos);
1198                ostrcatbig(&buf, tmpnr, &maxlen, &pos);
1199                ostrcatbig(&buf, "</a>", &maxlen, &pos);
1200                free(tmpnr); tmpnr = NULL;
1201        }
1202       
1203        ostrcatbig(&buf, "</td></tr></table></center></body></html>", &maxlen, &pos);
1204        return buf;
1205}
1206
1207void webgetshoot(char* param)
1208{
1209        char* cmd = NULL, *tmpstr = NULL;
1210
1211        if(status.aktservice->channel != NULL)
1212        {
1213                cmd = ostrcat(cmd, "grab.sh ", 1, 0);
1214                cmd = ostrcat(cmd, param, 1, 0);
1215                cmd = ostrcat(cmd, " ", 1, 0);
1216                cmd = ostrcat(cmd, getconfig("streamport", NULL), 1, 0);
1217                cmd = ostrcat(cmd, " ", 1, 0);
1218                tmpstr = oitoa(status.aktservice->channel->serviceid);
1219                cmd = ostrcat(cmd, tmpstr, 1, 0);
1220                free(tmpstr); tmpstr = NULL;
1221                cmd = ostrcat(cmd, ",", 1, 0);
1222                tmpstr = olutoa(status.aktservice->channel->transponderid);
1223                cmd = ostrcat(cmd, tmpstr, 1, 0);
1224                free(tmpstr); tmpstr = NULL;
1225                cmd = ostrcat(cmd, " titan", 1, 0);
1226        }
1227
1228        if(cmd != NULL)
1229                system(cmd);
1230        free(cmd);
1231}
1232
1233char* webgetepgsearch(char* query, char* param)
1234{
1235        int line = 0, maxlen = 0, pos = 0, maxcount = 0, page = 1;
1236        char* buf = NULL, *buf1 = NULL, *buf2 = NULL, *tmpstr = NULL, *tmpnr = NULL, * param1 = NULL;
1237        struct channel* chnode = channel;
1238        struct epg* epgnode = NULL;
1239        struct tm *loctime = NULL;
1240
1241        if(query == NULL) return NULL;
1242
1243        if(param == NULL)
1244        {
1245                query = strchr(query, '=');
1246                if(query != NULL)
1247                {
1248                        query++;
1249                        stringreplacechar(param, '+', ' ');
1250                        param = query;
1251                }
1252        }
1253        else
1254        {
1255                //create param1
1256                param1 = strchr(param, '&');
1257                if(param1 != NULL)
1258                {
1259                        *param1++ = '\0';
1260                        page = atoi(param1);
1261                }       
1262        }
1263
1264        buf1 = malloc(MINMALLOC);
1265        if(buf1 == NULL)
1266        {
1267                err("no mem");
1268                return buf;
1269        }
1270
1271        webcreateheadbig(&buf, &maxlen, NULL, &pos, 0);
1272        while(chnode != NULL)
1273        {
1274                epgnode = getepgakt(chnode);
1275                while(epgnode != NULL)
1276                {
1277                        //TODO: case sensitiv search
1278                        if(epgnode->title != NULL && strstr(epgnode->title, param) != NULL)
1279                        {
1280
1281                                maxcount++;
1282                                if(maxcount <= (MAXHTMLLINE * page) - MAXHTMLLINE || maxcount > MAXHTMLLINE * page)
1283                                {
1284                                        epgnode = epgnode->next;
1285                                        continue;
1286                                }
1287
1288                                if(line == 0)
1289                                {
1290                                        ostrcatbig(&buf, "<tr class=line1>", &maxlen, &pos);
1291                                        line = 1;
1292                                }
1293                                else
1294                                {
1295                                        ostrcatbig(&buf, "<tr class=line2>", &maxlen, &pos);
1296                                        line = 0;
1297                                }
1298
1299                                ostrcatbig(&buf, "<td nowrap><a target=main class=link href=query?getepg&", &maxlen, &pos);
1300                                tmpstr = oitoa(chnode->serviceid);
1301                                buf2 = ostrcat("<td nowrap><a target=main class=link href=query?addrectimer&",tmpstr, 0, 0);
1302                                buf2 = ostrcat(buf2, "&", 0, 0);
1303                                ostrcatbig(&buf, tmpstr, &maxlen, &pos);
1304                                free(tmpstr); tmpstr = NULL;
1305                                ostrcatbig(&buf, "&", &maxlen, &pos);
1306                                tmpstr = olutoa(chnode->transponderid);
1307                                ostrcatbig(&buf, tmpstr, &maxlen, &pos);
1308                                buf2 = ostrcat(buf2, tmpstr, 0, 0);
1309                                buf2 = ostrcat(buf2, "&", 0, 0);
1310                                free(tmpstr); tmpstr = NULL;
1311                                ostrcatbig(&buf, "&", &maxlen, &pos);
1312                                tmpstr = oitoa(epgnode->eventid);
1313                                ostrcatbig(&buf, tmpstr, &maxlen, &pos);
1314                                buf2 = ostrcat(buf2, tmpstr, 0, 0);
1315                                buf2 = ostrcat(buf2, ">", 0, 0);
1316                                free(tmpstr); tmpstr = NULL;
1317                                ostrcatbig(&buf, ">", &maxlen, &pos);
1318       
1319                                loctime = olocaltime(&epgnode->starttime);
1320                                if(loctime != NULL)
1321                                        strftime(buf1, MINMALLOC, "%d.%m _ %H:%M __ ", loctime);
1322                                        //strftime(buf1, MINMALLOC, "%H:%M -", loctime);
1323                                free(loctime); loctime = NULL;
1324                                //loctime = olocaltime(&epgnode->endtime);
1325                                //if(loctime != NULL)
1326                                //      strftime(&buf1[7], MINMALLOC - 8, " %H:%M ", loctime);
1327                                //free(loctime); loctime = NULL;
1328                                ostrcatbig(&buf, buf1, &maxlen, &pos);
1329                                ostrcatbig(&buf, " ", &maxlen, &pos);
1330       
1331                                ostrcatbig(&buf, epgnode->title, &maxlen, &pos);
1332                                if(chnode->name != NULL)
1333                                {
1334                                        ostrcatbig(&buf, " (", &maxlen, &pos);
1335                                        ostrcatbig(&buf, chnode->name, &maxlen, &pos);
1336                                        ostrcatbig(&buf, ")", &maxlen, &pos);
1337                                }
1338                                ostrcatbig(&buf, "</a><br><font class=smalllabel1>", &maxlen, &pos);
1339                                ostrcatbig(&buf, epgnode->subtitle, &maxlen, &pos);
1340                                ostrcatbig(&buf, "</font></td>", &maxlen, &pos);
1341                                ostrcatbig(&buf, buf2, &maxlen, &pos);
1342                                ostrcatbig(&buf, "<img border=0 width=16 height=16 src=img/timer.png alt=\"set timer\"/>", &maxlen, &pos);
1343                                ostrcatbig(&buf, "</a></td></tr>", &maxlen, &pos);
1344                        }
1345                        epgnode = epgnode->next;
1346                        free(buf2); buf2 = NULL;
1347                }
1348                chnode = chnode->next;
1349        }
1350
1351        if(maxcount > MAXHTMLLINE)
1352        {
1353                int i;
1354                ostrcatbig(&buf, "<tr><td align=center><br>", &maxlen, &pos);
1355                for(i = 1; i <= (int)ceil(((float)maxcount / MAXHTMLLINE)); i++)
1356                {
1357                        if(page == i)
1358                                ostrcatbig(&buf, "<a class=pagesellink href=query?getepgsearch&", &maxlen, &pos);
1359                        else
1360                                ostrcatbig(&buf, "<a class=pagelink href=query?getepgsearch&", &maxlen, &pos);
1361                        ostrcatbig(&buf, param, &maxlen, &pos);
1362                        ostrcatbig(&buf, "&", &maxlen, &pos);
1363                        free(tmpnr); tmpnr = NULL;
1364
1365                        tmpnr = oitoa(i);
1366                        ostrcatbig(&buf, tmpnr, &maxlen, &pos);
1367                        ostrcatbig(&buf, ">", &maxlen, &pos);
1368                        ostrcatbig(&buf, tmpnr, &maxlen, &pos);
1369                        ostrcatbig(&buf, "</a>", &maxlen, &pos);
1370                        free(tmpnr); tmpnr = NULL;
1371                }
1372                ostrcatbig(&buf, "</td></tr>", &maxlen, &pos);
1373        }
1374
1375        webcreatetailbig(&buf, &maxlen, &pos, 0);
1376        free(buf1);
1377        return buf;
1378}
1379
1380//flagbit 0: restrict to path
1381//flagbit 1: show epg icon
1382//flagbit 2: show delete icon
1383//flagbit 3: show stream icon
1384//flagbit 4: show websteam icon
1385char* webgetfilelist(char* param, char* link, char* dellink, char* path, char* mask, int flag)
1386{
1387        char* buf = NULL, *tmppath = NULL, *tmpnr = NULL, *param1 = NULL;
1388        int maxlen = 0, pos = 0, line = 0, maxcount = 0, page = 1;
1389        struct skin* webdir = getscreen("webdir");
1390        struct skin* filelist = getscreennode(webdir, "filelist");
1391        struct skin* filelistpath = getscreennode(webdir, "filelistpath");
1392        struct skin* node = NULL;
1393
1394        if(param == NULL) param = path;
1395
1396        //create param1
1397        param1 = strchr(param, '&');
1398        if(param1 != NULL)
1399                *param1++ = '\0';
1400
1401        if(param1 != NULL) page = atoi(param1);
1402
1403        if(strlen(param) == 0 || !isdir(param))
1404                tmppath = ostrcat(path, "", 0, 0);
1405        else
1406                tmppath = ostrcat(param, "", 0, 0);
1407
1408        char* tmppath1 = createpath(tmppath, "");
1409        free(tmppath); tmppath = tmppath1;
1410
1411        if(checkbit(flag, 0) == 1)
1412        {
1413                if(strstr(tmppath, path) != tmppath)
1414                {
1415                        free(tmppath); tmppath = NULL;
1416                        tmppath = ostrcat(path, "", 0, 0);
1417                }
1418        }
1419
1420        changemask(filelist, mask);
1421        changeinput(filelist, tmppath);
1422        changetext(filelistpath, filelist->input);
1423
1424        free(tmppath); tmppath = NULL;
1425
1426        delmarkedscreennodes(webdir, FILELISTDELMARK);
1427        createfilelist(webdir, filelist);
1428
1429        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);
1430
1431        node = filelist;
1432        while(node != NULL)
1433        {
1434                if(node->del == FILELISTDELMARK)
1435                {
1436                        maxcount++;
1437                        if(maxcount <= (MAXHTMLLINE * page) - MAXHTMLLINE || maxcount > MAXHTMLLINE * page)
1438                        {
1439                                node = node->next;
1440                                continue;
1441                        }
1442
1443                        if(line == 0)
1444                        {
1445                                ostrcatbig(&buf, "<tr class=line1>", &maxlen, &pos);
1446                                line = 1;
1447                        }
1448                        else
1449                        {
1450                                ostrcatbig(&buf, "<tr class=line2>", &maxlen, &pos);
1451                                line = 0;
1452                        }
1453
1454                        ostrcatbig(&buf, "<td>", &maxlen, &pos);
1455                        if(node->input != NULL) //dir
1456                        {
1457                                ostrcatbig(&buf, "<img border=0 width=16 height=16 src=img/folder.png alt=Directory> <a class=link href=\"query?", &maxlen, &pos);
1458                                ostrcatbig(&buf, link, &maxlen, &pos);
1459                                ostrcatbig(&buf, "&", &maxlen, &pos);
1460                                ostrcatbig(&buf, node->input, &maxlen, &pos);
1461                                ostrcatbig(&buf, "\">", &maxlen, &pos);
1462                                ostrcatbig(&buf, node->text, &maxlen, &pos);
1463                                ostrcatbig(&buf, "</a><td> </td>", &maxlen, &pos);
1464                        }
1465                        else
1466                        {
1467                                ostrcatbig(&buf, "<font class=label1>", &maxlen, &pos);
1468                                ostrcatbig(&buf, node->text, &maxlen, &pos);
1469                                ostrcatbig(&buf, "</font></td>", &maxlen, &pos);
1470
1471                                ostrcatbig(&buf, "<td width=80 align=right>", &maxlen, &pos);
1472                                //epg png
1473                                if(checkbit(flag, 1) == 1)
1474                                {
1475                                        ostrcatbig(&buf, "<a href=\"query?getmovieepg&", &maxlen, &pos);
1476                                        ostrcatbig(&buf, filelistpath->text, &maxlen, &pos);
1477                                        ostrcatbig(&buf, "/", &maxlen, &pos);
1478                                        ostrcatbig(&buf, node->text, &maxlen, &pos);
1479                                        ostrcatbig(&buf, "\">", &maxlen, &pos);
1480                                        ostrcatbig(&buf, "<img border=0 src=img/movieepg.png width=16 height=16 alt=EPG></a>", &maxlen, &pos);
1481                                }
1482                                //delete png
1483                                if(checkbit(flag, 2) == 1)
1484                                {
1485                                        ostrcatbig(&buf, "<img border=0 src=img/delete.png width=16 height=16 alt=Delete onclick='delquestion(\"", &maxlen, &pos);
1486                                        ostrcatbig(&buf, "query?", &maxlen, &pos);
1487                                        ostrcatbig(&buf, dellink, &maxlen, &pos);
1488                                        ostrcatbig(&buf, "&", &maxlen, &pos);
1489                                        ostrcatbig(&buf, filelistpath->text, &maxlen, &pos);
1490                                        ostrcatbig(&buf, "&", &maxlen, &pos);
1491                                        tmpnr = oitoa(page);
1492                                        ostrcatbig(&buf, tmpnr, &maxlen, &pos);
1493                                        free(tmpnr); tmpnr = NULL;
1494                                        ostrcatbig(&buf, "&", &maxlen, &pos);
1495                                        ostrcatbig(&buf, node->text, &maxlen, &pos);
1496                                        ostrcatbig(&buf, "\");'>", &maxlen, &pos);
1497                                }
1498                                //stream png
1499                                if(checkbit(flag, 3) == 1)
1500                                {
1501                                        ostrcatbig(&buf, "<a target=nothing href=\"query?getm3u&0,0,", &maxlen, &pos);
1502                                        ostrcatbig(&buf, filelistpath->text, &maxlen, &pos);
1503                                        ostrcatbig(&buf, "/", &maxlen, &pos);
1504                                        ostrcatbig(&buf, node->text, &maxlen, &pos);
1505                                        ostrcatbig(&buf, "\">", &maxlen, &pos);
1506
1507                                        ostrcatbig(&buf, "<img border=0 src=img/stream.png width=16 height=16 alt=Stream></a>", &maxlen, &pos);
1508                                }
1509                                //webstream png
1510                                if(checkbit(flag, 4) == 1)
1511                                {
1512                                        ostrcatbig(&buf, "<a target=_blank href=\"query?getvideo&0,0,", &maxlen, &pos);
1513                                        ostrcatbig(&buf, filelistpath->text, &maxlen, &pos);
1514                                        ostrcatbig(&buf, "/", &maxlen, &pos);
1515                                        ostrcatbig(&buf, node->text, &maxlen, &pos);
1516                                        ostrcatbig(&buf, "\">", &maxlen, &pos);
1517
1518                                        ostrcatbig(&buf, "<img border=0 src=img/webstream.png width=16 height=16 alt=WebStream></a>", &maxlen, &pos);
1519                                        //
1520                                        //
1521                                        ostrcatbig(&buf, "<a target=_blank href=\"", &maxlen, &pos);
1522                                        ostrcatbig(&buf, filelistpath->text, &maxlen, &pos);
1523                                        ostrcatbig(&buf, "/", &maxlen, &pos);
1524                                        ostrcatbig(&buf, node->text, &maxlen, &pos);
1525                                        ostrcatbig(&buf, "\">", &maxlen, &pos);
1526
1527                                        ostrcatbig(&buf, "<img border=0 src=img/icon_restart.png width=16 height=16 alt=Download></a>", &maxlen, &pos);
1528                                }
1529                        }
1530                        ostrcatbig(&buf, "</td>", &maxlen, &pos);
1531                        ostrcatbig(&buf, "</tr>", &maxlen, &pos);
1532                }
1533
1534                node = node->next;
1535        }
1536
1537        if(maxcount > MAXHTMLLINE)
1538        {
1539                int i;
1540                ostrcatbig(&buf, "<tr><td align=center><br>", &maxlen, &pos);
1541                for(i = 1; i <= (int)ceil(((float)maxcount / MAXHTMLLINE)); i++)
1542                {
1543                        if(page == i)
1544                        {
1545                                ostrcatbig(&buf, "<a class=pagesellink href=query?", &maxlen, &pos);
1546                                ostrcatbig(&buf, link, &maxlen, &pos);
1547                                ostrcatbig(&buf, "&", &maxlen, &pos);
1548                        }
1549                        else
1550                        {
1551                                ostrcatbig(&buf, "<a class=pagelink href=query?", &maxlen, &pos);
1552                                ostrcatbig(&buf, link, &maxlen, &pos);
1553                                ostrcatbig(&buf, "&", &maxlen, &pos);
1554                        }
1555                        ostrcatbig(&buf, param, &maxlen, &pos);
1556                        ostrcatbig(&buf, "&", &maxlen, &pos);
1557
1558                        tmpnr = oitoa(i);
1559                        ostrcatbig(&buf, tmpnr, &maxlen, &pos);
1560                        ostrcatbig(&buf, ">", &maxlen, &pos);
1561                        ostrcatbig(&buf, tmpnr, &maxlen, &pos);
1562                        ostrcatbig(&buf, "</a>", &maxlen, &pos);
1563                        free(tmpnr); tmpnr = NULL;
1564                }
1565                ostrcatbig(&buf, "</td></tr>", &maxlen, &pos);
1566        }
1567
1568        webcreatetailbig(&buf, &maxlen, &pos, 0);
1569        delmarkedscreennodes(webdir, FILELISTDELMARK);
1570        return buf;
1571}
1572
1573char* webgetmovieepg(char* param, char* path, int flag)
1574{
1575        char* buf = NULL, *tmpstr = NULL;
1576        char tstr[2];
1577        char c = 0;
1578        int first = 1, maxlen = 0, pos = 0;
1579        FILE* fd = NULL;
1580
1581        webcreateheadbig(&buf, &maxlen, NULL, &pos, 0);
1582        ostrcatbig(&buf, "<tr><td><font class=biglabel>", &maxlen, &pos);
1583
1584        if(flag == 1)
1585        {
1586                if(param != NULL && strstr(param, path) == param)
1587                {
1588                        tmpstr = changefilenameext(param, ".epg");
1589                        fd = fopen(tmpstr, "r");
1590                }
1591        }
1592        else
1593        {
1594                tmpstr = changefilenameext(param, ".epg");
1595                fd = fopen(tmpstr, "r");
1596        }
1597
1598        if(fd != NULL)
1599        {
1600                while(c != EOF)
1601                {
1602                        c = fgetc(fd);
1603                        if(c == '\n')
1604                        {
1605                                if(first == 1)
1606                                {
1607                                        ostrcatbig(&buf, "</font><br><font class=label>", &maxlen, &pos);
1608                                        first = 0;
1609                                }
1610                                ostrcatbig(&buf, "<br>", &maxlen, &pos);
1611                                continue;
1612                        }
1613                        sprintf(tstr, "%c", c);
1614                        ostrcatbig(&buf, tstr, &maxlen, &pos);
1615                }
1616                fclose(fd);
1617        }
1618        ostrcatbig(&buf, "</font></td></tr>", &maxlen, &pos);
1619
1620        webcreatetailbig(&buf, &maxlen, &pos, 0);
1621
1622        free(tmpstr); tmpstr = NULL;
1623        return buf;
1624}
1625
1626char* webdelfile(char* param, char* link, char* dellink, char* path, char* mask, int flag)
1627{
1628        char* buf = NULL, *param1 = NULL, *param2 = NULL, *tmpparam = NULL;
1629
1630        if(param == NULL) return NULL;
1631
1632        //create param1 + 2
1633        param1 = strchr(param, '&');
1634        if(param1 != NULL)
1635        {
1636                *param1++ = '\0';
1637                param2 = strchr(param1, '&');
1638                if(param2 != NULL)
1639                        *param2++ = '\0';
1640        }
1641
1642        if(param1 == NULL || param2 == NULL) return NULL;
1643
1644        tmpparam = createpath(param, param2);
1645
1646        if(checkbit(flag, 0) == 1)
1647        {
1648                if(tmpparam != NULL && strstr(tmpparam, path) == tmpparam)
1649                        unlink(tmpparam);
1650        }
1651        else
1652                unlink(tmpparam);
1653
1654        free(tmpparam); tmpparam = NULL;
1655        tmpparam = ostrcat(tmpparam, param, 1, 0);
1656        tmpparam = ostrcat(tmpparam, "&", 1, 0);
1657        tmpparam = ostrcat(tmpparam, param1, 1, 0);
1658
1659        buf = webgetfilelist(tmpparam, link, dellink, path, mask, flag);
1660        free(tmpparam); tmpparam = NULL;
1661        return buf;
1662}
1663
1664void websendrc(char* param)
1665{
1666        int rccode = 0;
1667
1668        rccode = getrcconfigint(param, NULL);
1669        writerc(rccode);
1670}
1671
1672//flag 0: get aktiv timer
1673//flag 1: get old timer
1674char* webgetrectimer(char* param, int flag)
1675{
1676        char* buf = NULL, *buf1 = NULL;
1677        struct rectimer* node = rectimer;
1678        struct channel* chnode = NULL;
1679        int line = 0, maxlen = 0, pos = 0;
1680        struct tm *loctime = NULL;
1681
1682        buf1 = malloc(MINMALLOC);
1683        if(buf1 == NULL)
1684        {
1685                err("no mem");
1686                return NULL;
1687        }
1688
1689        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);
1690
1691        while(node != NULL)
1692        {
1693                if((flag == 0 && (node->status == 2 || node->status == 3)) || (flag == 1 && (node->status == 0 || node->status == 1)))
1694                {
1695                        node = node->next;
1696                        continue;
1697                }
1698                if(line == 0)
1699                {
1700                        ostrcatbig(&buf, "<tr class=line1><td>", &maxlen, &pos);
1701                        line = 1;
1702                }
1703                else
1704                {
1705                        ostrcatbig(&buf, "<tr class=line2><td>", &maxlen, &pos);
1706                        line = 0;
1707                }
1708
1709                loctime = olocaltime(&node->begin);
1710                if(loctime != NULL)
1711                        strftime(buf1, MINMALLOC, "%d-%m-%Y %H:%M -", loctime);
1712                free(loctime); loctime = NULL;
1713                loctime = olocaltime(&node->end);
1714                if(loctime != NULL)
1715                        strftime(&buf1[18], MINMALLOC - 19, " %H:%M ", loctime);
1716                free(loctime); loctime = NULL;
1717
1718                ostrcatbig(&buf, "<font class=label1>", &maxlen, &pos);
1719                ostrcatbig(&buf, buf1, &maxlen, &pos);
1720
1721                ostrcatbig(&buf, " (", &maxlen, &pos);
1722                if(node->justplay == 0)
1723                        ostrcatbig(&buf, "rec - ", &maxlen, &pos);
1724                else
1725                        ostrcatbig(&buf, "switch - ", &maxlen, &pos);
1726                if(node->repeate == 0)
1727                        ostrcatbig(&buf, "once", &maxlen, &pos);
1728                else
1729                        ostrcatbig(&buf, "repeate", &maxlen, &pos);
1730
1731                ostrcatbig(&buf, ")</font><br><font class=smalllabel1>", &maxlen, &pos);
1732                if(node->name == NULL || strlen(node->name) == 0)
1733                        ostrcatbig(&buf, "---", &maxlen, &pos);
1734                else
1735                        ostrcatbig(&buf, node->name, &maxlen, &pos);
1736
1737                chnode = getchannel(node->serviceid, node->transponderid);
1738                if(chnode != NULL)
1739                {
1740                        ostrcatbig(&buf, " (", &maxlen, &pos);
1741                        ostrcatbig(&buf, chnode->name, &maxlen, &pos);
1742                        ostrcatbig(&buf, ")", &maxlen, &pos);
1743                }
1744                ostrcatbig(&buf, "<br>", &maxlen, &pos);
1745
1746                if(node->status == 0)
1747                        ostrcatbig(&buf, "waiting", &maxlen, &pos);
1748                else if(node->status == 1)
1749                        ostrcatbig(&buf, "running", &maxlen, &pos);
1750                else if(node->status == 2)
1751                        ostrcatbig(&buf, "succes", &maxlen, &pos);
1752                else if(node->status == 3)
1753                {
1754                        ostrcatbig(&buf, "error", &maxlen, &pos);
1755                        if(node->errstr != NULL && strlen(node->errstr) > 0)
1756                        {
1757                                ostrcatbig(&buf, " (", &maxlen, &pos);
1758                                ostrcatbig(&buf, node->errstr, &maxlen, &pos);
1759                                ostrcatbig(&buf, ")", &maxlen, &pos);
1760                        }
1761                }
1762
1763                ostrcatbig(&buf, "</font>", &maxlen, &pos);
1764
1765                if(flag == 0)
1766                {
1767                        ostrcatbig(&buf, "</td><td width=40 align=right>", &maxlen, &pos);
1768
1769                        //edit png
1770                        ostrcatbig(&buf, "<a target=main href=\"query?editrectimer", &maxlen, &pos);
1771                        ostrcatbig(&buf, "&", &maxlen, &pos);
1772                        ostrcatbig(&buf, node->timestamp, &maxlen, &pos);
1773                        ostrcatbig(&buf, "\">", &maxlen, &pos);
1774
1775                        ostrcatbig(&buf, "<img border=0 src=img/edit.png width=16 height=16 alt=\"Edit Timer\"></a>", &maxlen, &pos);
1776
1777                        //delete png
1778                        ostrcatbig(&buf, "<img border=0 src=img/delete.png width=16 height=16 alt=Delete onclick='delquestion(\"", &maxlen, &pos);
1779                        ostrcatbig(&buf, "query?delrectimer", &maxlen, &pos);
1780                        ostrcatbig(&buf, "&", &maxlen, &pos);
1781                        ostrcatbig(&buf, node->timestamp, &maxlen, &pos);
1782                        //ostrcatbig(&buf, filelistpath->text, &maxlen, &pos);
1783                        //ostrcatbig(&buf, "&", &maxlen, &pos);
1784                        //tmpnr = oitoa(page);
1785                        //ostrcatbig(&buf, tmpnr, &maxlen, &pos);
1786                        //free(tmpnr); tmpnr = NULL;
1787                        //ostrcatbig(&buf, "&", &maxlen, &pos);
1788                        //ostrcatbig(&buf, node->text, &maxlen, &pos);
1789                        ostrcatbig(&buf, "\");'>", &maxlen, &pos);
1790                }
1791
1792                ostrcatbig(&buf, "</td></tr>", &maxlen, &pos);
1793
1794                node = node->next;
1795        }
1796
1797        webcreatetailbig(&buf, &maxlen, &pos, 0);
1798
1799        free(buf1);
1800        return buf;
1801}
1802
1803char* webaddrectimer(char* param)
1804{
1805        char* buf = NULL, *buf1 = NULL, *buf2 = NULL, *param1 = NULL, *param2 = NULL;
1806        struct channel* chnode = NULL;
1807        struct epg* epgnode = NULL;
1808//      int maxlen = 0, pos = 0, tmpservicetype = 0;
1809        int maxlen = 0, pos = 0;
1810        struct tm* loctime = NULL;
1811        time_t akttime = time(NULL);
1812       
1813        if(param != NULL)
1814        {
1815                //create param1 + 2
1816                param1 = strchr(param, '&');
1817                if(param1 != NULL)
1818                {
1819                        *param1++ = '\0';
1820                        param2 = strchr(param1, '&');
1821                        if(param2 != NULL)
1822                                *param2++ = '\0';
1823                }
1824                if(param1 == NULL || param2 == NULL) return NULL;
1825                chnode = getchannel(atoi(param), atoi(param1));
1826                if(chnode == NULL) return NULL;
1827
1828                epgnode = getepg(chnode, atoi(param2), 0);
1829                if(epgnode == NULL) return NULL;
1830        }
1831
1832               
1833        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);
1834        ostrcatbig(&buf, "<body class=body ><center>", &maxlen, &pos);
1835        ostrcatbig(&buf, "<form name=F1 action=query method=get><br><br>", &maxlen, &pos);
1836        ostrcatbig(&buf, "<input type=\"hidden\" name=\"rectimersend&node\" value=\"", &maxlen, &pos);
1837        ostrcatbig(&buf, "0", &maxlen, &pos);
1838        ostrcatbig(&buf, "\">", &maxlen, &pos);
1839        ostrcatbig(&buf, "<table border=\"0\"><tr>", &maxlen, &pos);
1840        ostrcatbig(&buf, "<td><font class=label>Name:&nbsp;</font></td>", &maxlen, &pos);
1841        ostrcatbig(&buf, "<td><input class=inputbox type=\"text\" name=\"name\" value=\"", &maxlen, &pos);
1842        if(epgnode != NULL)
1843                ostrcatbig(&buf, epgnode->title, &maxlen, &pos);
1844        else   
1845                ostrcatbig(&buf, " ", &maxlen, &pos);
1846        ostrcatbig(&buf, "\" /></td></tr>", &maxlen, &pos);
1847        ostrcatbig(&buf, "<td><font class=label>Type:&nbsp;</font></td>", &maxlen, &pos);
1848        ostrcatbig(&buf, "<td><select name=\"type\" border=0><option selected>", &maxlen, &pos);
1849        ostrcatbig(&buf, "record", &maxlen, &pos);
1850        ostrcatbig(&buf, "<option>record<option>switch channel</select></td></tr>", &maxlen, &pos);
1851
1852        buf2 = malloc(MINMALLOC);
1853        if(epgnode != NULL)
1854                loctime =       olocaltime(&epgnode->starttime);
1855        else
1856                loctime = olocaltime(&akttime);
1857        strftime(buf2, MINMALLOC, "%H:%M %d-%m-%Y", loctime);
1858        free(loctime); loctime = NULL;
1859
1860        buf1 = ostrcat(buf2, "", 0, 0);
1861        ostrcatbig(&buf, "<td><font class=label>Begin:&nbsp;</font></td>", &maxlen, &pos);
1862        ostrcatbig(&buf, "<td><input class=inputbox type=\"text\" name=\"begin\" value=\"", &maxlen, &pos);
1863        ostrcatbig(&buf, buf1, &maxlen, &pos);
1864        ostrcatbig(&buf, "\" /></td></tr>", &maxlen, &pos);
1865        free(buf1); buf1 = NULL;
1866       
1867        if(epgnode != NULL)
1868                loctime =       olocaltime(&epgnode->endtime);
1869        else
1870                loctime = olocaltime(&akttime);
1871        strftime(buf2, MINMALLOC, "%H:%M %d-%m-%Y", loctime);
1872        free(loctime); loctime = NULL;
1873       
1874        buf1 = ostrcat(buf2, "", 0, 0);
1875        ostrcatbig(&buf, "<td><font class=label>End:&nbsp;</font></td>", &maxlen, &pos);
1876        ostrcatbig(&buf, "<td><input class=inputbox type=\"text\" name=\"end\" value=\"", &maxlen, &pos);
1877        ostrcatbig(&buf, buf1, &maxlen, &pos);
1878        ostrcatbig(&buf, "\" /></td></tr>", &maxlen, &pos);
1879        free(buf1); buf1 = NULL;
1880        free(buf2); buf2 = NULL;
1881
1882        ostrcatbig(&buf, "<td><font class=label>Channel:&nbsp;</font></td>", &maxlen, &pos);
1883        ostrcatbig(&buf, "<td><input class=inputbox type=\"text\" name=\"channel\" value=\"", &maxlen, &pos);
1884        if(chnode != NULL)
1885                ostrcatbig(&buf, chnode->name, &maxlen, &pos);
1886        else if(status.aktservice->channel != NULL)
1887                ostrcatbig(&buf, status.aktservice->channel->name, &maxlen, &pos);
1888        ostrcatbig(&buf, "\" /></td></tr>", &maxlen, &pos);
1889        free(buf1); buf1 = NULL;
1890       
1891        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);
1892
1893        //ostrcatbig(&buf, param, &maxlen, &pos);
1894        return buf;
1895}
1896
1897char* webrectimersend(char* param)
1898{
1899        char* buf = NULL, *string = NULL, *name = NULL, *begin = NULL, *end = NULL, *type = NULL, *anode = NULL, *channelname = NULL, *sid = NULL, *tid = NULL, *ext = NULL;
1900//      int maxlen = 0, pos = 0, newnode = 0, channelfind = 0;
1901        int newnode = 0, channelfind = 0;
1902        struct rectimer *node = NULL;
1903        char* tmpstr = NULL;
1904        struct tm* loctime = NULL;
1905        struct channel *channel1 = NULL;
1906//      struct service *service1;
1907
1908        anode = strstr(param, "node=");
1909        if(anode != NULL)
1910                anode = anode + 5;
1911        name = strstr(param, "name=");
1912        if(name != NULL)
1913                name = name + 5;
1914        begin = strstr(param, "begin=");
1915        if(begin != NULL)
1916                begin = begin + 6;
1917        end = strstr(param, "end=");
1918        if(end != NULL)
1919                end = end + 4;
1920        type = strstr(param, "type=");
1921        if(type != NULL)
1922                type = type + 5;
1923        channelname = strstr(param, "channel=");
1924        if(channelname != NULL)
1925                channelname = channelname + 8;
1926        sid = strstr(param, "sid=");
1927        if(sid != NULL)
1928                sid = sid + 4;
1929        tid = strstr(param, "tid=");
1930        if(tid != NULL)
1931                tid = tid + 4;
1932        ext = strstr(param, "ext=");
1933        if(ext != NULL)
1934                ext = ext + 4;
1935       
1936        string = param;
1937        while(string != NULL)
1938        {       
1939                string = strchr(string, '&');
1940                if(string != NULL)
1941                        *string++ = '\0';
1942        }
1943       
1944        string = channelname;   
1945        while(string != NULL)
1946        {       
1947                string = strchr(string, '+');
1948                if(string != NULL)
1949                        *string++ = ' ';
1950        }
1951
1952        string = name; 
1953        while(string != NULL)
1954        {       
1955                string = strchr(string, '+');
1956                if(string != NULL)
1957                        *string++ = ' ';
1958        }
1959       
1960        if((sid == NULL && tid != NULL) || (sid != NULL && tid == NULL))
1961        {
1962                buf = ostrcat(buf, "ERROR: sid and tid required or only channel", 1, 0);       
1963                return buf;
1964        }
1965               
1966       
1967        if(channelname != NULL && sid == NULL)
1968        {
1969                channelfind = 0;
1970                channel1 = channel;
1971                while(channel1 != NULL)
1972                {
1973                        if(ostrcmp(channel1->name, channelname) == 0 && channel1->servicetype == 0) {
1974                                if(channelnottunable(channel1) == 0)
1975                                {
1976                                        channelfind = 1;
1977                                        break;
1978                                }
1979                        }
1980                        channel1 = channel1->next;
1981                }
1982                if(channelfind == 0)
1983                {
1984                        channel1 = channel;             
1985                        while(channel1 != NULL)
1986                        {
1987                                if(strstr(channel1->name, channelname) != NULL && channel1->servicetype == 0)
1988                                {
1989                                        if(channelnottunable(channel1) == 0)
1990                                        {
1991                                                channelfind = 1;
1992                                                break;
1993                                        }
1994                                }
1995                                channel1 = channel1->next;
1996                        }
1997                }
1998                if(channelfind == 0)
1999                {
2000                        buf = ostrcat(buf, "ERROR: channel not found", 1, 0);   
2001                        return buf;
2002                }
2003        }
2004       
2005        newnode = 0;
2006        node = getrectimerbytimestamp(anode);
2007        if(node == NULL)
2008        {
2009                node = addrectimernode(NULL, NULL);
2010                if(node != NULL)
2011                {
2012                        newnode = 1;
2013                        node->pincode = ostrcat("0000", NULL, 0, 0);
2014                        node->recpath = ostrcat(NULL, getconfig("rec_path", NULL), 0, 0);
2015                        node->afterevent = 0;
2016                        node->repeate = 0;
2017                }
2018        }
2019       
2020        if(node != NULL)
2021        {
2022                if(channelfind == 1 && channel1 != NULL)
2023                {
2024                        node->serviceid = channel1->serviceid;
2025                        node->servicetype = channel1->servicetype;
2026                        node->transponderid = channel1->transponderid;
2027                }
2028       
2029                if(sid != NULL && tid != NULL)
2030                {
2031                        node->serviceid = atoi(sid);
2032                        node->transponderid = atol(tid);
2033                        node->servicetype = 0;
2034                }
2035       
2036                free(node->name); node->name = NULL;
2037                node->name = ostrcat(name, "", 0, 0);
2038       
2039                if(ostrcmp(type, "record") == 0)
2040                        node->justplay = 0;
2041                else
2042                        node->justplay = 1;
2043       
2044                loctime = olocaltime(&node->begin);
2045                tmpstr = strptime(begin, "%H:%M+%d-%m-%Y", loctime);
2046                if(tmpstr != NULL)
2047                        node->begin = mktime(loctime);
2048                node->begin -= (node->begin % 60);
2049                tmpstr = NULL;
2050                free(loctime); loctime = NULL;
2051
2052                loctime = olocaltime(&node->end);
2053                tmpstr = strptime(end, "%H:%M+%d-%m-%Y", loctime);
2054                if(tmpstr != NULL)
2055                        node->end = mktime(loctime);
2056                node->end -= (node->end % 60);
2057                tmpstr = NULL;
2058                free(loctime); loctime = NULL;
2059
2060                if(newnode == 1)
2061                        node->disabled = 0;
2062       
2063                status.writerectimer = 1;
2064                writerectimer(getconfig("rectimerfile", NULL), 0);
2065               
2066                if(ext == NULL)
2067                        buf = webgetrectimer(NULL, 0);
2068                else
2069                {
2070                        buf = ostrcat(buf, "ok -> TimerID=", 1, 0);
2071                        buf = ostrcat(buf, node->timestamp, 1, 0);
2072                }
2073        }
2074        else
2075                buf = ostrcat(buf, "Timer not ok", 1, 0);
2076
2077        return buf;
2078}
2079
2080char* webeditrectimer(char* param)
2081{
2082        char* buf = NULL, *buf1 = NULL, *buf2 = NULL;
2083        int maxlen = 0, pos = 0;
2084        struct rectimer *node = NULL;
2085        struct tm* loctime = NULL;
2086
2087        node = getrectimerbytimestamp(param);
2088        if(node == NULL) return NULL;
2089               
2090        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);
2091        ostrcatbig(&buf, "<body class=body ><center>", &maxlen, &pos);
2092        ostrcatbig(&buf, "<form name=F1 action=query method=get><br><br>", &maxlen, &pos);
2093        ostrcatbig(&buf, "<input type=\"hidden\" name=\"rectimersend&node\" value=\"", &maxlen, &pos);
2094        ostrcatbig(&buf, node->timestamp, &maxlen, &pos);
2095        ostrcatbig(&buf, "\">", &maxlen, &pos);
2096        ostrcatbig(&buf, "<table border=\"0\"><tr>", &maxlen, &pos);
2097        ostrcatbig(&buf, "<td><font class=label>Name:&nbsp;</font></td>", &maxlen, &pos);
2098        ostrcatbig(&buf, "<td><input class=inputbox type=\"text\" name=\"name\" value=\"", &maxlen, &pos);
2099        ostrcatbig(&buf, node->name, &maxlen, &pos);
2100        ostrcatbig(&buf, "\" /></td></tr>", &maxlen, &pos);
2101
2102        ostrcatbig(&buf, "<td><font class=label>Type:&nbsp;</font></td>", &maxlen, &pos);
2103        ostrcatbig(&buf, "<td><select name=\"type\" border=0><option selected>", &maxlen, &pos);
2104        if( node->justplay == 0 )
2105                ostrcatbig(&buf, "record", &maxlen, &pos);
2106        else
2107                ostrcatbig(&buf, "switch channel", &maxlen, &pos);
2108        ostrcatbig(&buf, "<option>record<option>switch channel</select></td></tr>", &maxlen, &pos);
2109       
2110        /*ostrcatbig(&buf, "<td><font class=label>Repeate:&nbsp;</font></td>", &maxlen, &pos);
2111        ostrcatbig(&buf, "<td><select name=\"repeate\" border=0><option selected>", &maxlen, &pos);
2112        if( node->repeate == 0 )
2113                ostrcatbig(&buf, "once", &maxlen, &pos);
2114        else
2115                ostrcatbig(&buf, "repeate", &maxlen, &pos);
2116        ostrcatbig(&buf, "<option>once<option>repeate</select></td></tr>", &maxlen, &pos);     
2117        */
2118       
2119        /*ostrcatbig(&buf, "<td><font class=label>Repeate type:&nbsp;</font></td>", &maxlen, &pos);
2120        ostrcatbig(&buf, "<td><select name=\"repeatetype\" border=0><option selected>", &maxlen, &pos);
2121        if( node->repeate == 0 )
2122                ostrcatbig(&buf, "daily", &maxlen, &pos);
2123        else if( node->repeate == 1 )
2124                ostrcatbig(&buf, "weekly", &maxlen, &pos);
2125        else if( node->repeate == 2 )
2126                ostrcatbig(&buf, "workdays", &maxlen, &pos);
2127        else
2128                ostrcatbig(&buf, "user defined", &maxlen, &pos);
2129        ostrcatbig(&buf, "<option>daily<option>weekly<option>workdays<option>user defined</select></td></tr>", &maxlen, &pos); 
2130        */
2131               
2132        buf2 = malloc(MINMALLOC);
2133        loctime = olocaltime(&node->begin);
2134        strftime(buf2, MINMALLOC, "%H:%M %d-%m-%Y", loctime);
2135        free(loctime); loctime = NULL;
2136
2137        buf1 = ostrcat(buf2, "", 0, 0);
2138        ostrcatbig(&buf, "<td><font class=label>Begin:&nbsp;</font></td>", &maxlen, &pos);
2139        ostrcatbig(&buf, "<td><input class=inputbox type=\"text\" name=\"begin\" value=\"", &maxlen, &pos);
2140        ostrcatbig(&buf, buf1, &maxlen, &pos);
2141        ostrcatbig(&buf, "\" /></td></tr>", &maxlen, &pos);
2142        free(buf1); buf1 = NULL;
2143       
2144        loctime = olocaltime(&node->end);
2145        strftime(buf2, MINMALLOC, "%H:%M %d-%m-%Y", loctime);
2146        free(loctime); loctime = NULL;
2147
2148        buf1 = ostrcat(buf2, "", 0, 0);
2149        ostrcatbig(&buf, "<td><font class=label>End:&nbsp;</font></td>", &maxlen, &pos);
2150        ostrcatbig(&buf, "<td><input class=inputbox type=\"text\" name=\"end\" value=\"", &maxlen, &pos);
2151        ostrcatbig(&buf, buf1, &maxlen, &pos);
2152        ostrcatbig(&buf, "\" /></td></tr>", &maxlen, &pos);
2153        free(buf1); buf1 = NULL;
2154        free(buf2); buf2 = NULL;
2155       
2156        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);
2157       
2158        //ostrcatbig(&buf, param, &maxlen, &pos);
2159        return buf;
2160}
2161
2162char* webdelrectimer(char* param)
2163{
2164        char* buf = NULL, *string = NULL, *timerid = NULL;
2165        struct rectimer *node = NULL;
2166        int ext = 0;
2167       
2168        timerid = strstr(param, "timerid=");
2169        if(timerid != NULL)
2170        {
2171                timerid = timerid + 8;
2172                ext = 1;
2173        }
2174
2175        node = NULL;
2176        if(ext == 1)
2177        {
2178                string = param;
2179                while(string != NULL)
2180                {       
2181                        string = strchr(string, '&');
2182                        if(string != NULL)
2183                                *string++ = '\0';
2184                }
2185                node = getrectimerbytimestamp(timerid);
2186        }
2187        else
2188                node = getrectimerbytimestamp(param);
2189
2190        if(node == NULL)
2191        {
2192                buf = ostrcat(buf, "ERROR: timer not found", 1, 0);     
2193                return buf;
2194        }
2195       
2196        delrectimer(node, 1, 0);
2197       
2198        if(ext == 1)
2199                buf = ostrcat(buf, "ok -> timer deleted", 1, 0);
2200        else
2201                buf = webgetrectimer(NULL, 0);
2202       
2203        return buf;
2204}
2205
2206void putxmessage(struct stimerthread* timernode, char* captiontime, char* body)
2207{
2208        struct splitstr* ret1 = NULL;
2209        char* caption = NULL;
2210        int count1 = 0;
2211        int timeout = 5;
2212
2213        ret1 = strsplit(captiontime, "\t", &count1);
2214
2215        if(count1 >= 2)
2216        {
2217                caption = ostrcat(caption, (&ret1[0])->part, 1, 0);
2218                if((&ret1[1])->part != NULL)
2219                        timeout = atoi((&ret1[1])->part);
2220                textbox(caption, body, _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 280, timeout, 0);
2221        }
2222
2223        free(caption); free(body); free(captiontime); free(ret1);
2224}
2225
2226void xmessage(char* filename)
2227{
2228        char* param=NULL, *param1 = NULL, *param2 = NULL, *param3 = NULL, *param4 = NULL;
2229        char* caption=NULL, *body=NULL;
2230        char* timeout=NULL;
2231
2232        param4 = strstr(filename, "icon=");
2233        param3 = strstr(filename, "charset=");
2234        param2 = strstr(filename, "timeout=");
2235        param1 = strstr(filename, "caption=");
2236        param = strstr(filename, "body=");
2237
2238        if(param4 != NULL)
2239        {
2240                param4 = param4 - 1;
2241                *param4 = '\0';
2242                param4 = param4 + 5;
2243                *param4++ = '\0';
2244        }
2245        if(param3 != NULL)
2246        {
2247                param3 = param3 - 1;
2248                *param3 = '\0';
2249                param3 = param3 + 8;
2250                *param3++ = '\0';
2251        }
2252        if(param2 != NULL)
2253        {
2254                param2 = param2 - 1;
2255                *param2 = '\0';
2256                param2 = param2 + 8;
2257                *param2++ = '\0';
2258        }
2259        if(param1 != NULL)
2260        {
2261                param1 = param1 - 1;
2262                *param1 = '\0';
2263                param1 = param1 + 8;
2264                *param1++ = '\0';
2265        }
2266        if(param != NULL)
2267        {
2268                param = param - 1;
2269                *param = '\0';
2270                param = param + 5;
2271                *param++ = '\0';
2272                body = ostrcat(body, param, 1, 0);
2273        }
2274        else
2275                body = ostrcat(body, " ", 1, 0);
2276               
2277        if(param2 != NULL)
2278                timeout = ostrcat(timeout, param2, 1, 0);
2279        else
2280                timeout = ostrcat(timeout, "5", 1, 0);
2281               
2282        if(param1 != NULL)
2283                caption = ostrcat(caption, param1, 1, 0);
2284        else
2285                caption = ostrcat(caption, "XMESSAGE", 1, 0);
2286       
2287        caption = ostrcat(caption, "\t", 1, 0);
2288        caption = ostrcat(caption, timeout, 1, 1);
2289               
2290        addtimer(&putxmessage, START, 1000, 1, (void*)caption, (void*)body, NULL);
2291        return;
2292}
2293
2294#endif
Note: See TracBrowser for help on using the repository browser.