source: titan/titan/httpdfunc.h @ 11361

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

[titan] fix

File size: 58.6 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(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(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, _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, 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, *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                ostrcatbig(&buf, "<td nowrap><a target=main class=link href=query?getepg&", &maxlen, &pos);
981                tmpstr = oitoa(chnode->serviceid);
982                ostrcatbig(&buf, tmpstr, &maxlen, &pos);
983                free(tmpstr); tmpstr = NULL;
984                ostrcatbig(&buf, "&", &maxlen, &pos);
985                tmpstr = olutoa(chnode->transponderid);
986                ostrcatbig(&buf, tmpstr, &maxlen, &pos);
987                free(tmpstr); tmpstr = NULL;
988                ostrcatbig(&buf, "&", &maxlen, &pos);
989                tmpstr = oitoa(epgnode->eventid);
990                ostrcatbig(&buf, tmpstr, &maxlen, &pos);
991                free(tmpstr); tmpstr = NULL;
992                ostrcatbig(&buf, ">", &maxlen, &pos);
993
994                loctime = olocaltime(&epgnode->starttime);
995                if(loctime != NULL)
996                        strftime(buf1, MINMALLOC, "%H:%M -", loctime);
997                free(loctime); loctime = NULL;
998                loctime = olocaltime(&epgnode->endtime);
999                if(loctime != NULL)
1000                        strftime(&buf1[7], MINMALLOC - 8, " %H:%M ", loctime);
1001                free(loctime); loctime = NULL;
1002                ostrcatbig(&buf, buf1, &maxlen, &pos);
1003                ostrcatbig(&buf, " ", &maxlen, &pos);
1004                ostrcatbig(&buf, epgnode->title, &maxlen, &pos);
1005                if(epgnode->subtitle != NULL)
1006                {
1007                        ostrcatbig(&buf, " (", &maxlen, &pos);
1008                        ostrcatbig(&buf, epgnode->subtitle, &maxlen, &pos);
1009                        ostrcatbig(&buf, ")", &maxlen, &pos);
1010                }
1011                ostrcatbig(&buf, "</a></td></tr>", &maxlen, &pos);
1012       
1013                epgnode = epgnode->next;
1014        }
1015
1016        webcreatetailbig(&buf, &maxlen, &pos, 0);
1017
1018        free(buf1);
1019        return buf;
1020}
1021
1022//TODO: create rectimer line
1023void webcalcrecline(char** buf, int* maxlen, int* pos)
1024{
1025        //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);
1026}
1027
1028char* webgetgmultiepg(char* param)
1029{
1030        int page = 1, i, line = 0, treffer = 0, maxlen = 0, pos = 0;
1031        char* buf = NULL, *tmpnr = NULL, *param1 = NULL;
1032        struct mainbouquet *mbouquet = NULL;
1033        struct bouquet *node = NULL;
1034        struct channel* chnode = NULL;
1035        struct epg* epgnode = NULL;
1036        time_t akttime = 0, difftime = 0, starttime = 0, endtime = 0, lastendtime = 0;
1037
1038        if(param == NULL) return NULL;
1039
1040        //create param1
1041        param1 = strchr(param, '&');
1042        if(param1 != NULL)
1043                *param1++ = '\0';
1044
1045        if(param1 != NULL) page = atoi(param1);
1046
1047        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);
1048
1049        akttime = webcreatetimeline(&buf, &maxlen, &pos);
1050        akttime += ((page - 1) * 1440);
1051        ostrcatbig(&buf, "</tr></thead><tbody>", &maxlen, &pos);
1052
1053        mbouquet = getmainbouquet(param);
1054        if(mbouquet != NULL)
1055        {
1056                node = mbouquet->bouquet;
1057                while(node != NULL)
1058                {
1059                        chnode = getchannel(node->serviceid, node->transponderid);
1060                        if(chnode != NULL)
1061                        {
1062                                if(line == 0)
1063                                {
1064                                        ostrcatbig(&buf, "<tr><th class=gepgchannel1>", &maxlen, &pos);
1065                                        ostrcatbig(&buf, chnode->name, &maxlen, &pos);
1066                                        ostrcatbig(&buf, "</th><td class=gepgchannelcell colspan=1000>", &maxlen, &pos);
1067                                        webcalcrecline(&buf, &maxlen, &pos);
1068                                        ostrcatbig(&buf, "<table border=0 cellpadding=0 cellspacing=0 style=\"table-layout: fixed;\"><tr class=line1>", &maxlen, &pos);
1069                                        line = 1;
1070                                }
1071                                else
1072                                {
1073                                        ostrcatbig(&buf, "<tr><th class=gepgchannel2>", &maxlen, &pos);
1074                                        ostrcatbig(&buf, chnode->name, &maxlen, &pos);
1075                                        ostrcatbig(&buf, "</th><td class=gepgchannelcell colspan=1000>", &maxlen, &pos);
1076                                        webcalcrecline(&buf, &maxlen, &pos);
1077
1078                                        ostrcatbig(&buf, "<table border=0 cellpadding=0 cellspacing=0 style=\"table-layout: fixed;\"><tr class=line2>", &maxlen, &pos);
1079                                        line = 0;
1080                                }
1081
1082                                treffer = 0;
1083                                lastendtime = 0;
1084                                epgnode = getepgakt(chnode);
1085                                while(epgnode != NULL)
1086                                {
1087                                        treffer = 1;
1088                                        starttime = epgnode->starttime / 60;
1089                                        endtime = epgnode->endtime / 60;
1090
1091                                        if(endtime <= starttime || starttime >= akttime + 1440)
1092                                        {
1093                                                epgnode = epgnode->next;
1094                                                continue;
1095                                        }
1096
1097                                        //check if old endtime > new starttime
1098                                        if(lastendtime > 0 && starttime > lastendtime)
1099                                        {
1100                                                difftime = (starttime - lastendtime) * 5;
1101
1102                                                if(difftime <= 0)
1103                                                {
1104                                                        epgnode = epgnode->next;
1105                                                        continue;
1106                                                }
1107
1108                                                ostrcatbig(&buf, "<td class=gepgcellblank style=\"", &maxlen, &pos);
1109                                                tmpnr = oitoa(difftime);
1110                                                ostrcatbig(&buf, "width:", &maxlen, &pos);
1111                                                ostrcatbig(&buf, tmpnr, &maxlen, &pos);
1112                                                ostrcatbig(&buf, "px;", &maxlen, &pos);
1113                                                ostrcatbig(&buf, "min-width:", &maxlen, &pos);
1114                                                ostrcatbig(&buf, tmpnr, &maxlen, &pos);
1115                                                ostrcatbig(&buf, "px;", &maxlen, &pos);
1116                                                ostrcatbig(&buf, "max-width:", &maxlen, &pos);
1117                                                ostrcatbig(&buf, tmpnr, &maxlen, &pos);
1118                                                ostrcatbig(&buf, "px;", &maxlen, &pos);
1119                                                free(tmpnr); tmpnr = NULL;
1120
1121                                                ostrcatbig(&buf, "\"> </td>", &maxlen, &pos);
1122                                        }
1123
1124                                        //check if starttime < last endtime
1125                                        if(starttime < lastendtime)
1126                                                starttime = lastendtime;
1127
1128                                        //check if endtime is in next day
1129                                        if(endtime > akttime + 1440)
1130                                                endtime = endtime - (endtime - (akttime + 1440));
1131
1132                                        //check if starttime is in prev day
1133                                        if(starttime < akttime)
1134                                                difftime = (endtime - akttime) * 5;
1135                                        else
1136                                                difftime = (endtime - starttime) * 5;
1137
1138                                        if(difftime <= 0)
1139                                        {
1140                                                epgnode = epgnode->next;
1141                                                continue;
1142                                        }
1143
1144                                        lastendtime = endtime;
1145
1146                                        ostrcatbig(&buf, "<td class=gepgcell style=\"", &maxlen, &pos);
1147                                        tmpnr = oitoa(difftime);
1148                                        ostrcatbig(&buf, "width:", &maxlen, &pos);
1149                                        ostrcatbig(&buf, tmpnr, &maxlen, &pos);
1150                                        ostrcatbig(&buf, "px;", &maxlen, &pos);
1151                                        ostrcatbig(&buf, "min-width:", &maxlen, &pos);
1152                                        ostrcatbig(&buf, tmpnr, &maxlen, &pos);
1153                                        ostrcatbig(&buf, "px;", &maxlen, &pos);
1154                                        ostrcatbig(&buf, "max-width:", &maxlen, &pos);
1155                                        ostrcatbig(&buf, tmpnr, &maxlen, &pos);
1156                                        ostrcatbig(&buf, "px;", &maxlen, &pos);
1157                                        free(tmpnr); tmpnr = NULL;
1158
1159                                        ostrcatbig(&buf, "\"><div class=gepgcellborder>", &maxlen, &pos);
1160                                        ostrcatbig(&buf, epgnode->title, &maxlen, &pos);
1161                                        ostrcatbig(&buf, "</div></div></td>", &maxlen, &pos);
1162                                       
1163                                        epgnode = epgnode->next;
1164                                }
1165                                if(treffer == 0)
1166                                        ostrcatbig(&buf, "<td class=gepgcellblank> </td>", &maxlen, &pos);
1167                        }
1168                        ostrcatbig(&buf, "</tr></table></td></tr>", &maxlen, &pos);
1169
1170                        node = node->next;
1171                }
1172        }
1173        ostrcatbig(&buf, "<script type=text/javascript>if(typeof tableScroll == 'function'){tableScroll('gmultiepg');}</script></tbody></table></td></tr><tr><td align=center>", &maxlen, &pos);
1174
1175        for(i = 1; i <= 14; i++)
1176        {
1177                if(page == i)
1178                        ostrcatbig(&buf, "<a class=pagesellink href=\"query?getgmultiepg&", &maxlen, &pos);
1179                else
1180                        ostrcatbig(&buf, "<a class=pagelink href=\"query?getgmultiepg&", &maxlen, &pos);
1181                ostrcatbig(&buf, param, &maxlen, &pos);
1182                ostrcatbig(&buf, "&", &maxlen, &pos);
1183                tmpnr = oitoa(i);
1184                ostrcatbig(&buf, tmpnr, &maxlen, &pos);
1185                ostrcatbig(&buf, "\">", &maxlen, &pos);
1186                ostrcatbig(&buf, tmpnr, &maxlen, &pos);
1187                ostrcatbig(&buf, "</a>", &maxlen, &pos);
1188                free(tmpnr); tmpnr = NULL;
1189        }
1190       
1191        ostrcatbig(&buf, "</td></tr></table></center></body></html>", &maxlen, &pos);
1192        return buf;
1193}
1194
1195void webgetshoot(char* param)
1196{
1197        char* cmd = NULL, *tmpstr = NULL;
1198
1199        if(status.aktservice->channel != NULL)
1200        {
1201                cmd = ostrcat(cmd, "grab.sh ", 1, 0);
1202                cmd = ostrcat(cmd, param, 1, 0);
1203                cmd = ostrcat(cmd, " ", 1, 0);
1204                cmd = ostrcat(cmd, getconfig("streamport", NULL), 1, 0);
1205                cmd = ostrcat(cmd, " ", 1, 0);
1206                tmpstr = oitoa(status.aktservice->channel->serviceid);
1207                cmd = ostrcat(cmd, tmpstr, 1, 0);
1208                free(tmpstr); tmpstr = NULL;
1209                cmd = ostrcat(cmd, ",", 1, 0);
1210                tmpstr = olutoa(status.aktservice->channel->transponderid);
1211                cmd = ostrcat(cmd, tmpstr, 1, 0);
1212                free(tmpstr); tmpstr = NULL;
1213                cmd = ostrcat(cmd, " titan", 1, 0);
1214        }
1215
1216        if(cmd != NULL)
1217                system(cmd);
1218        free(cmd);
1219}
1220
1221char* webgetepgsearch(char* query, char* param)
1222{
1223        int line = 0, maxlen = 0, pos = 0, maxcount = 0, page = 1;
1224        char* buf = NULL, *buf1 = NULL, *tmpstr = NULL, *tmpnr = NULL, * param1 = NULL;
1225        struct channel* chnode = channel;
1226        struct epg* epgnode = NULL;
1227        struct tm *loctime = NULL;
1228
1229        if(query == NULL) return NULL;
1230
1231        if(param == NULL)
1232        {
1233                query = strchr(query, '=');
1234                if(query != NULL)
1235                {
1236                        query++;
1237                        stringreplacechar(param, '+', ' ');
1238                        param = query;
1239                }
1240        }
1241        else
1242        {
1243                //create param1
1244                param1 = strchr(param, '&');
1245                if(param1 != NULL)
1246                {
1247                        *param1++ = '\0';
1248                        page = atoi(param1);
1249                }       
1250        }
1251
1252        buf1 = malloc(MINMALLOC);
1253        if(buf1 == NULL)
1254        {
1255                err("no mem");
1256                return buf;
1257        }
1258
1259        webcreateheadbig(&buf, &maxlen, NULL, &pos, 0);
1260        while(chnode != NULL)
1261        {
1262                epgnode = getepgakt(chnode);
1263                while(epgnode != NULL)
1264                {
1265                        //TODO: case sensitiv search
1266                        if(epgnode->title != NULL && strstr(epgnode->title, param) != NULL)
1267                        {
1268
1269                                maxcount++;
1270                                if(maxcount <= (MAXHTMLLINE * page) - MAXHTMLLINE || maxcount > MAXHTMLLINE * page)
1271                                {
1272                                        epgnode = epgnode->next;
1273                                        continue;
1274                                }
1275
1276                                if(line == 0)
1277                                {
1278                                        ostrcatbig(&buf, "<tr class=line1>", &maxlen, &pos);
1279                                        line = 1;
1280                                }
1281                                else
1282                                {
1283                                        ostrcatbig(&buf, "<tr class=line2>", &maxlen, &pos);
1284                                        line = 0;
1285                                }
1286
1287                                ostrcatbig(&buf, "<td nowrap><a target=main class=link href=query?getepg&", &maxlen, &pos);
1288                                tmpstr = oitoa(chnode->serviceid);
1289                                ostrcatbig(&buf, tmpstr, &maxlen, &pos);
1290                                free(tmpstr); tmpstr = NULL;
1291                                ostrcatbig(&buf, "&", &maxlen, &pos);
1292                                tmpstr = olutoa(chnode->transponderid);
1293                                ostrcatbig(&buf, tmpstr, &maxlen, &pos);
1294                                free(tmpstr); tmpstr = NULL;
1295                                ostrcatbig(&buf, "&", &maxlen, &pos);
1296                                tmpstr = oitoa(epgnode->eventid);
1297                                ostrcatbig(&buf, tmpstr, &maxlen, &pos);
1298                                free(tmpstr); tmpstr = NULL;
1299                                ostrcatbig(&buf, ">", &maxlen, &pos);
1300       
1301                                loctime = olocaltime(&epgnode->starttime);
1302                                if(loctime != NULL)
1303                                        strftime(buf1, MINMALLOC, "%H:%M -", loctime);
1304                                free(loctime); loctime = NULL;
1305                                loctime = olocaltime(&epgnode->endtime);
1306                                if(loctime != NULL)
1307                                        strftime(&buf1[7], MINMALLOC - 8, " %H:%M ", loctime);
1308                                free(loctime); loctime = NULL;
1309                                ostrcatbig(&buf, buf1, &maxlen, &pos);
1310                                ostrcatbig(&buf, " ", &maxlen, &pos);
1311       
1312                                ostrcatbig(&buf, epgnode->title, &maxlen, &pos);
1313                                if(chnode->name != NULL)
1314                                {
1315                                        ostrcatbig(&buf, " (", &maxlen, &pos);
1316                                        ostrcatbig(&buf, chnode->name, &maxlen, &pos);
1317                                        ostrcatbig(&buf, ")", &maxlen, &pos);
1318                                }
1319                                ostrcatbig(&buf, "</a><br><font class=smalllabel1>", &maxlen, &pos);
1320                                ostrcatbig(&buf, epgnode->subtitle, &maxlen, &pos);
1321                                ostrcatbig(&buf, "</font></td></tr>", &maxlen, &pos);
1322                        }
1323                        epgnode = epgnode->next;
1324                }
1325                chnode = chnode->next;
1326        }
1327
1328        if(maxcount > MAXHTMLLINE)
1329        {
1330                int i;
1331                ostrcatbig(&buf, "<tr><td align=center><br>", &maxlen, &pos);
1332                for(i = 1; i <= (int)ceil(((float)maxcount / MAXHTMLLINE)); i++)
1333                {
1334                        if(page == i)
1335                                ostrcatbig(&buf, "<a class=pagesellink href=query?getepgsearch&", &maxlen, &pos);
1336                        else
1337                                ostrcatbig(&buf, "<a class=pagelink href=query?getepgsearch&", &maxlen, &pos);
1338                        ostrcatbig(&buf, param, &maxlen, &pos);
1339                        ostrcatbig(&buf, "&", &maxlen, &pos);
1340                        free(tmpnr); tmpnr = NULL;
1341
1342                        tmpnr = oitoa(i);
1343                        ostrcatbig(&buf, tmpnr, &maxlen, &pos);
1344                        ostrcatbig(&buf, ">", &maxlen, &pos);
1345                        ostrcatbig(&buf, tmpnr, &maxlen, &pos);
1346                        ostrcatbig(&buf, "</a>", &maxlen, &pos);
1347                        free(tmpnr); tmpnr = NULL;
1348                }
1349                ostrcatbig(&buf, "</td></tr>", &maxlen, &pos);
1350        }
1351
1352        webcreatetailbig(&buf, &maxlen, &pos, 0);
1353        free(buf1);
1354        return buf;
1355}
1356
1357//flagbit 0: restrict to path
1358//flagbit 1: show epg icon
1359//flagbit 2: show delete icon
1360//flagbit 3: show stream icon
1361//flagbit 4: show websteam icon
1362char* webgetfilelist(char* param, char* link, char* dellink, char* path, char* mask, int flag)
1363{
1364        char* buf = NULL, *tmppath = NULL, *tmpnr = NULL, *param1 = NULL;
1365        int maxlen = 0, pos = 0, line = 0, maxcount = 0, page = 1;
1366        struct skin* webdir = getscreen("webdir");
1367        struct skin* filelist = getscreennode(webdir, "filelist");
1368        struct skin* filelistpath = getscreennode(webdir, "filelistpath");
1369        struct skin* node = NULL;
1370
1371        if(param == NULL) param = path;
1372
1373        //create param1
1374        param1 = strchr(param, '&');
1375        if(param1 != NULL)
1376                *param1++ = '\0';
1377
1378        if(param1 != NULL) page = atoi(param1);
1379
1380        if(strlen(param) == 0 || !isdir(param))
1381                tmppath = ostrcat(path, "", 0, 0);
1382        else
1383                tmppath = ostrcat(param, "", 0, 0);
1384
1385        char* tmppath1 = createpath(tmppath, "");
1386        free(tmppath); tmppath = tmppath1;
1387
1388        if(checkbit(flag, 0) == 1)
1389        {
1390                if(strstr(tmppath, path) != tmppath)
1391                {
1392                        free(tmppath); tmppath = NULL;
1393                        tmppath = ostrcat(path, "", 0, 0);
1394                }
1395        }
1396
1397        changemask(filelist, mask);
1398        changeinput(filelist, tmppath);
1399        changetext(filelistpath, filelist->input);
1400
1401        free(tmppath); tmppath = NULL;
1402
1403        delmarkedscreennodes(webdir, FILELISTDELMARK);
1404        createfilelist(webdir, filelist);
1405
1406        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);
1407
1408        node = filelist;
1409        while(node != NULL)
1410        {
1411                if(node->del == FILELISTDELMARK)
1412                {
1413                        maxcount++;
1414                        if(maxcount <= (MAXHTMLLINE * page) - MAXHTMLLINE || maxcount > MAXHTMLLINE * page)
1415                        {
1416                                node = node->next;
1417                                continue;
1418                        }
1419
1420                        if(line == 0)
1421                        {
1422                                ostrcatbig(&buf, "<tr class=line1>", &maxlen, &pos);
1423                                line = 1;
1424                        }
1425                        else
1426                        {
1427                                ostrcatbig(&buf, "<tr class=line2>", &maxlen, &pos);
1428                                line = 0;
1429                        }
1430
1431                        ostrcatbig(&buf, "<td>", &maxlen, &pos);
1432                        if(node->input != NULL) //dir
1433                        {
1434                                ostrcatbig(&buf, "<img border=0 width=16 height=16 src=img/folder.png alt=Directory> <a class=link href=\"query?", &maxlen, &pos);
1435                                ostrcatbig(&buf, link, &maxlen, &pos);
1436                                ostrcatbig(&buf, "&", &maxlen, &pos);
1437                                ostrcatbig(&buf, node->input, &maxlen, &pos);
1438                                ostrcatbig(&buf, "\">", &maxlen, &pos);
1439                                ostrcatbig(&buf, node->text, &maxlen, &pos);
1440                                ostrcatbig(&buf, "</a><td> </td>", &maxlen, &pos);
1441                        }
1442                        else
1443                        {
1444                                ostrcatbig(&buf, "<font class=label1>", &maxlen, &pos);
1445                                ostrcatbig(&buf, node->text, &maxlen, &pos);
1446                                ostrcatbig(&buf, "</font></td>", &maxlen, &pos);
1447
1448                                ostrcatbig(&buf, "<td width=80 align=right>", &maxlen, &pos);
1449                                //epg png
1450                                if(checkbit(flag, 1) == 1)
1451                                {
1452                                        ostrcatbig(&buf, "<a href=\"query?getmovieepg&", &maxlen, &pos);
1453                                        ostrcatbig(&buf, filelistpath->text, &maxlen, &pos);
1454                                        ostrcatbig(&buf, "/", &maxlen, &pos);
1455                                        ostrcatbig(&buf, node->text, &maxlen, &pos);
1456                                        ostrcatbig(&buf, "\">", &maxlen, &pos);
1457                                        ostrcatbig(&buf, "<img border=0 src=img/movieepg.png width=16 height=16 alt=EPG></a>", &maxlen, &pos);
1458                                }
1459                                //delete png
1460                                if(checkbit(flag, 2) == 1)
1461                                {
1462                                        ostrcatbig(&buf, "<img border=0 src=img/delete.png width=16 height=16 alt=Delete onclick='delquestion(\"", &maxlen, &pos);
1463                                        ostrcatbig(&buf, "query?", &maxlen, &pos);
1464                                        ostrcatbig(&buf, dellink, &maxlen, &pos);
1465                                        ostrcatbig(&buf, "&", &maxlen, &pos);
1466                                        ostrcatbig(&buf, filelistpath->text, &maxlen, &pos);
1467                                        ostrcatbig(&buf, "&", &maxlen, &pos);
1468                                        tmpnr = oitoa(page);
1469                                        ostrcatbig(&buf, tmpnr, &maxlen, &pos);
1470                                        free(tmpnr); tmpnr = NULL;
1471                                        ostrcatbig(&buf, "&", &maxlen, &pos);
1472                                        ostrcatbig(&buf, node->text, &maxlen, &pos);
1473                                        ostrcatbig(&buf, "\");'>", &maxlen, &pos);
1474                                }
1475                                //stream png
1476                                if(checkbit(flag, 3) == 1)
1477                                {
1478                                        ostrcatbig(&buf, "<a target=nothing href=\"query?getm3u&0,0,", &maxlen, &pos);
1479                                        ostrcatbig(&buf, filelistpath->text, &maxlen, &pos);
1480                                        ostrcatbig(&buf, "/", &maxlen, &pos);
1481                                        ostrcatbig(&buf, node->text, &maxlen, &pos);
1482                                        ostrcatbig(&buf, "\">", &maxlen, &pos);
1483
1484                                        ostrcatbig(&buf, "<img border=0 src=img/stream.png width=16 height=16 alt=Stream></a>", &maxlen, &pos);
1485                                }
1486                                //webstream png
1487                                if(checkbit(flag, 4) == 1)
1488                                {
1489                                        ostrcatbig(&buf, "<a target=_blank href=\"query?getvideo&0,0,", &maxlen, &pos);
1490                                        ostrcatbig(&buf, filelistpath->text, &maxlen, &pos);
1491                                        ostrcatbig(&buf, "/", &maxlen, &pos);
1492                                        ostrcatbig(&buf, node->text, &maxlen, &pos);
1493                                        ostrcatbig(&buf, "\">", &maxlen, &pos);
1494
1495                                        ostrcatbig(&buf, "<img border=0 src=img/webstream.png width=16 height=16 alt=WebStream></a>", &maxlen, &pos);
1496                                }
1497                        }
1498                        ostrcatbig(&buf, "</td>", &maxlen, &pos);
1499                        ostrcatbig(&buf, "</tr>", &maxlen, &pos);
1500                }
1501
1502                node = node->next;
1503        }
1504
1505        if(maxcount > MAXHTMLLINE)
1506        {
1507                int i;
1508                ostrcatbig(&buf, "<tr><td align=center><br>", &maxlen, &pos);
1509                for(i = 1; i <= (int)ceil(((float)maxcount / MAXHTMLLINE)); i++)
1510                {
1511                        if(page == i)
1512                        {
1513                                ostrcatbig(&buf, "<a class=pagesellink href=query?", &maxlen, &pos);
1514                                ostrcatbig(&buf, link, &maxlen, &pos);
1515                                ostrcatbig(&buf, "&", &maxlen, &pos);
1516                        }
1517                        else
1518                        {
1519                                ostrcatbig(&buf, "<a class=pagelink href=query?", &maxlen, &pos);
1520                                ostrcatbig(&buf, link, &maxlen, &pos);
1521                                ostrcatbig(&buf, "&", &maxlen, &pos);
1522                        }
1523                        ostrcatbig(&buf, param, &maxlen, &pos);
1524                        ostrcatbig(&buf, "&", &maxlen, &pos);
1525
1526                        tmpnr = oitoa(i);
1527                        ostrcatbig(&buf, tmpnr, &maxlen, &pos);
1528                        ostrcatbig(&buf, ">", &maxlen, &pos);
1529                        ostrcatbig(&buf, tmpnr, &maxlen, &pos);
1530                        ostrcatbig(&buf, "</a>", &maxlen, &pos);
1531                        free(tmpnr); tmpnr = NULL;
1532                }
1533                ostrcatbig(&buf, "</td></tr>", &maxlen, &pos);
1534        }
1535
1536        webcreatetailbig(&buf, &maxlen, &pos, 0);
1537        delmarkedscreennodes(webdir, FILELISTDELMARK);
1538        return buf;
1539}
1540
1541char* webgetmovieepg(char* param, char* path, int flag)
1542{
1543        char* buf = NULL, *tmpstr = NULL;
1544        char tstr[2];
1545        char c = 0;
1546        int first = 1, maxlen = 0, pos = 0;
1547        FILE* fd = NULL;
1548
1549        webcreateheadbig(&buf, &maxlen, NULL, &pos, 0);
1550        ostrcatbig(&buf, "<tr><td><font class=biglabel>", &maxlen, &pos);
1551
1552        if(flag == 1)
1553        {
1554                if(param != NULL && strstr(param, path) == param)
1555                {
1556                        tmpstr = changefilenameext(param, ".epg");
1557                        fd = fopen(tmpstr, "r");
1558                }
1559        }
1560        else
1561        {
1562                tmpstr = changefilenameext(param, ".epg");
1563                fd = fopen(tmpstr, "r");
1564        }
1565
1566        if(fd != NULL)
1567        {
1568                while(c != EOF)
1569                {
1570                        c = fgetc(fd);
1571                        if(c == '\n')
1572                        {
1573                                if(first == 1)
1574                                {
1575                                        ostrcatbig(&buf, "</font><br><font class=label>", &maxlen, &pos);
1576                                        first = 0;
1577                                }
1578                                ostrcatbig(&buf, "<br>", &maxlen, &pos);
1579                                continue;
1580                        }
1581                        sprintf(tstr, "%c", c);
1582                        ostrcatbig(&buf, tstr, &maxlen, &pos);
1583                }
1584                fclose(fd);
1585        }
1586        ostrcatbig(&buf, "</font></td></tr>", &maxlen, &pos);
1587
1588        webcreatetailbig(&buf, &maxlen, &pos, 0);
1589
1590        free(tmpstr); tmpstr = NULL;
1591        return buf;
1592}
1593
1594char* webdelfile(char* param, char* link, char* dellink, char* path, char* mask, int flag)
1595{
1596        char* buf = NULL, *param1 = NULL, *param2 = NULL, *tmpparam = NULL;
1597
1598        if(param == NULL) return NULL;
1599
1600        //create param1 + 2
1601        param1 = strchr(param, '&');
1602        if(param1 != NULL)
1603        {
1604                *param1++ = '\0';
1605                param2 = strchr(param1, '&');
1606                if(param2 != NULL)
1607                        *param2++ = '\0';
1608        }
1609
1610        if(param1 == NULL || param2 == NULL) return NULL;
1611
1612        tmpparam = createpath(param, param2);
1613
1614        if(checkbit(flag, 0) == 1)
1615        {
1616                if(tmpparam != NULL && strstr(tmpparam, path) == tmpparam)
1617                        unlink(tmpparam);
1618        }
1619        else
1620                unlink(tmpparam);
1621
1622        free(tmpparam); tmpparam = NULL;
1623        tmpparam = ostrcat(tmpparam, param, 1, 0);
1624        tmpparam = ostrcat(tmpparam, "&", 1, 0);
1625        tmpparam = ostrcat(tmpparam, param1, 1, 0);
1626
1627        buf = webgetfilelist(tmpparam, link, dellink, path, mask, flag);
1628        free(tmpparam); tmpparam = NULL;
1629        return buf;
1630}
1631
1632void websendrc(char* param)
1633{
1634        int rccode = 0;
1635
1636        rccode = getrcconfigint(param, NULL);
1637        writerc(rccode);
1638}
1639
1640//flag 0: get aktiv timer
1641//flag 1: get old timer
1642char* webgetrectimer(char* param, int flag)
1643{
1644        char* buf = NULL, *buf1 = NULL, *tmpnr = NULL;
1645        struct rectimer* node = rectimer;
1646        struct channel* chnode = NULL;
1647        int line = 0, maxlen = 0, pos = 0;
1648        struct tm *loctime = NULL;
1649
1650        buf1 = malloc(MINMALLOC);
1651        if(buf1 == NULL)
1652        {
1653                err("no mem");
1654                return NULL;
1655        }
1656
1657        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);
1658
1659        while(node != NULL)
1660        {
1661                if((flag == 0 && (node->status == 2 || node->status == 3)) || (flag == 1 && (node->status == 0 || node->status == 1)))
1662                {
1663                        node = node->next;
1664                        continue;
1665                }
1666                if(line == 0)
1667                {
1668                        ostrcatbig(&buf, "<tr class=line1><td>", &maxlen, &pos);
1669                        line = 1;
1670                }
1671                else
1672                {
1673                        ostrcatbig(&buf, "<tr class=line2><td>", &maxlen, &pos);
1674                        line = 0;
1675                }
1676
1677                loctime = olocaltime(&node->begin);
1678                if(loctime != NULL)
1679                        strftime(buf1, MINMALLOC, "%d-%m-%Y %H:%M -", loctime);
1680                free(loctime); loctime = NULL;
1681                loctime = olocaltime(&node->end);
1682                if(loctime != NULL)
1683                        strftime(&buf1[18], MINMALLOC - 19, " %H:%M ", loctime);
1684                free(loctime); loctime = NULL;
1685
1686                ostrcatbig(&buf, "<font class=label1>", &maxlen, &pos);
1687                ostrcatbig(&buf, buf1, &maxlen, &pos);
1688
1689                ostrcatbig(&buf, " (", &maxlen, &pos);
1690                if(node->justplay == 0)
1691                        ostrcatbig(&buf, "rec - ", &maxlen, &pos);
1692                else
1693                        ostrcatbig(&buf, "switch - ", &maxlen, &pos);
1694                if(node->repeate == 0)
1695                        ostrcatbig(&buf, "once", &maxlen, &pos);
1696                else
1697                        ostrcatbig(&buf, "repeate", &maxlen, &pos);
1698
1699                ostrcatbig(&buf, ")</font><br><font class=smalllabel1>", &maxlen, &pos);
1700                if(node->name == NULL || strlen(node->name) == 0)
1701                        ostrcatbig(&buf, "---", &maxlen, &pos);
1702                else
1703                        ostrcatbig(&buf, node->name, &maxlen, &pos);
1704
1705                chnode = getchannel(node->serviceid, node->transponderid);
1706                if(chnode != NULL)
1707                {
1708                        ostrcatbig(&buf, " (", &maxlen, &pos);
1709                        ostrcatbig(&buf, chnode->name, &maxlen, &pos);
1710                        ostrcatbig(&buf, ")", &maxlen, &pos);
1711                }
1712                ostrcatbig(&buf, "<br>", &maxlen, &pos);
1713
1714                if(node->status == 0)
1715                        ostrcatbig(&buf, "waiting", &maxlen, &pos);
1716                else if(node->status == 1)
1717                        ostrcatbig(&buf, "running", &maxlen, &pos);
1718                else if(node->status == 2)
1719                        ostrcatbig(&buf, "succes", &maxlen, &pos);
1720                else if(node->status == 3)
1721                {
1722                        ostrcatbig(&buf, "error", &maxlen, &pos);
1723                        if(node->errstr != NULL && strlen(node->errstr) > 0)
1724                        {
1725                                ostrcatbig(&buf, " (", &maxlen, &pos);
1726                                ostrcatbig(&buf, node->errstr, &maxlen, &pos);
1727                                ostrcatbig(&buf, ")", &maxlen, &pos);
1728                        }
1729                }
1730
1731                ostrcatbig(&buf, "</font>", &maxlen, &pos);
1732
1733                if(flag == 0)
1734                {
1735                        ostrcatbig(&buf, "</td><td width=40 align=right>", &maxlen, &pos);
1736
1737                        //edit png
1738                        ostrcatbig(&buf, "<a target=main href=\"query?editrectimer", &maxlen, &pos);
1739                        ostrcatbig(&buf, "&", &maxlen, &pos);
1740                        tmpnr = oitoa(node);
1741                        ostrcatbig(&buf, tmpnr, &maxlen, &pos);
1742                        free(tmpnr); tmpnr = NULL;
1743                        //ostrcatbig(&buf, node->text, &maxlen, &pos);
1744                        ostrcatbig(&buf, "\">", &maxlen, &pos);
1745
1746                        ostrcatbig(&buf, "<img border=0 src=img/edit.png width=16 height=16 alt=\"Edit Timer\"></a>", &maxlen, &pos);
1747
1748                        //delete png
1749                        ostrcatbig(&buf, "<img border=0 src=img/delete.png width=16 height=16 alt=Delete onclick='delquestion(\"", &maxlen, &pos);
1750                        ostrcatbig(&buf, "query?delrectimer", &maxlen, &pos);
1751                        ostrcatbig(&buf, "&", &maxlen, &pos);
1752                        tmpnr = oitoa(node);
1753                        ostrcatbig(&buf, tmpnr, &maxlen, &pos);
1754                        free(tmpnr); tmpnr = NULL;
1755        //ostrcatbig(&buf, filelistpath->text, &maxlen, &pos);
1756                        //ostrcatbig(&buf, "&", &maxlen, &pos);
1757                        //tmpnr = oitoa(page);
1758                        //ostrcatbig(&buf, tmpnr, &maxlen, &pos);
1759                        //free(tmpnr); tmpnr = NULL;
1760                        //ostrcatbig(&buf, "&", &maxlen, &pos);
1761                        //ostrcatbig(&buf, node->text, &maxlen, &pos);
1762                        ostrcatbig(&buf, "\");'>", &maxlen, &pos);
1763                }
1764
1765                ostrcatbig(&buf, "</td></tr>", &maxlen, &pos);
1766
1767                node = node->next;
1768        }
1769
1770        webcreatetailbig(&buf, &maxlen, &pos, 0);
1771
1772        free(buf1);
1773        return buf;
1774}
1775
1776char* webaddrectimer(char* param)
1777{
1778        char* buf = NULL;
1779        int maxlen = 0, pos = 0;
1780       
1781        ostrcatbig(&buf, param, &maxlen, &pos);
1782        return buf;
1783}
1784
1785char* webrectimersend(char* param)
1786{
1787        char* buf = NULL, *string = NULL, *name = NULL, *begin = NULL, *end = NULL, *type = NULL, *node = NULL;
1788        int maxlen = 0, pos = 0;
1789
1790        node=strstr(param, "node=");
1791        if(node != NULL)
1792                node = node + 5;
1793        name=strstr(param, "name=");
1794        if(name != NULL)
1795                name = name + 5;
1796        begin=strstr(param, "begin=");
1797        if(begin != NULL)
1798                begin = begin + 6;
1799        end=strstr(param, "end=");
1800        if(end != NULL)
1801                end = end + 4;
1802        type=strstr(param, "type=");
1803        if(type != NULL)
1804                type = type + 5;
1805       
1806        string = param;
1807        while(string != NULL) {
1808                string = strchr(string, '&');
1809                if(string != NULL)
1810                        *string++ = '\0';
1811        }
1812       
1813        ostrcatbig(&buf, param, &maxlen, &pos);
1814        return buf;
1815}
1816
1817char* webeditrectimer(char* param)
1818{
1819        char* buf = NULL, *buf1 = NULL, *buf2 = NULL, *tmpnr = NULL;
1820        int maxlen = 0, pos = 0;
1821        struct rectimer *node = NULL;
1822        struct tm* loctime = NULL;
1823        node = atoi(param);
1824               
1825        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);
1826        ostrcatbig(&buf, "<body class=body ><center>", &maxlen, &pos);
1827        ostrcatbig(&buf, "<form name=F1 action=query method=get><br><br>", &maxlen, &pos);
1828        ostrcatbig(&buf, "<input type=\"hidden\" name=\"rectimersend&node\" value=\"", &maxlen, &pos);
1829        tmpnr = oitoa(node);
1830        ostrcatbig(&buf, tmpnr, &maxlen, &pos);
1831        free(tmpnr); tmpnr = NULL;
1832        ostrcatbig(&buf, "\">", &maxlen, &pos);
1833        ostrcatbig(&buf, "<table border=\"0\"><tr>", &maxlen, &pos);
1834        ostrcatbig(&buf, "<td><font class=label>Name:&nbsp;</font></td>", &maxlen, &pos);
1835        ostrcatbig(&buf, "<td><input class=inputbox type=\"text\" name=\"name\" value=\"", &maxlen, &pos);
1836        ostrcatbig(&buf, node->name, &maxlen, &pos);
1837        ostrcatbig(&buf, "\" /></td></tr>", &maxlen, &pos);
1838
1839        ostrcatbig(&buf, "<td><font class=label>Type:&nbsp;</font></td>", &maxlen, &pos);
1840        ostrcatbig(&buf, "<td><select name=\"type\" border=0><option selected>", &maxlen, &pos);
1841        if( node->justplay == 0 )
1842                ostrcatbig(&buf, "record", &maxlen, &pos);
1843        else
1844                ostrcatbig(&buf, "switch channel", &maxlen, &pos);
1845        ostrcatbig(&buf, "<option>record<option>switch channel</select></td></tr>", &maxlen, &pos);
1846       
1847        /*ostrcatbig(&buf, "<td><font class=label>Repeate:&nbsp;</font></td>", &maxlen, &pos);
1848        ostrcatbig(&buf, "<td><select name=\"repeate\" border=0><option selected>", &maxlen, &pos);
1849        if( node->repeate == 0 )
1850                ostrcatbig(&buf, "once", &maxlen, &pos);
1851        else
1852                ostrcatbig(&buf, "repeate", &maxlen, &pos);
1853        ostrcatbig(&buf, "<option>once<option>repeate</select></td></tr>", &maxlen, &pos);     
1854        */
1855       
1856        /*ostrcatbig(&buf, "<td><font class=label>Repeate type:&nbsp;</font></td>", &maxlen, &pos);
1857        ostrcatbig(&buf, "<td><select name=\"repeatetype\" border=0><option selected>", &maxlen, &pos);
1858        if( node->repeate == 0 )
1859                ostrcatbig(&buf, "daily", &maxlen, &pos);
1860        else if( node->repeate == 1 )
1861                ostrcatbig(&buf, "weekly", &maxlen, &pos);
1862        else if( node->repeate == 2 )
1863                ostrcatbig(&buf, "workdays", &maxlen, &pos);
1864        else
1865                ostrcatbig(&buf, "user defined", &maxlen, &pos);
1866        ostrcatbig(&buf, "<option>daily<option>weekly<option>workdays<option>user defined</select></td></tr>", &maxlen, &pos); 
1867        */
1868               
1869        buf2 = malloc(MINMALLOC);
1870        loctime = localtime(&node->begin);
1871        strftime(buf2, MINMALLOC, "%H:%M %d-%m-%Y", loctime);
1872        buf1 = ostrcat(buf2, "", 0, 0);
1873        ostrcatbig(&buf, "<td><font class=label>Begin:&nbsp;</font></td>", &maxlen, &pos);
1874        ostrcatbig(&buf, "<td><input class=inputbox type=\"text\" name=\"begin\" value=\"", &maxlen, &pos);
1875        ostrcatbig(&buf, buf1, &maxlen, &pos);
1876        ostrcatbig(&buf, "\" /></td></tr>", &maxlen, &pos);
1877        free(buf1); buf1 = NULL;
1878       
1879        loctime = localtime(&node->end);
1880        strftime(buf2, MINMALLOC, "%H:%M %d-%m-%Y", loctime);
1881        buf1 = ostrcat(buf2, "", 0, 0);
1882        ostrcatbig(&buf, "<td><font class=label>End:&nbsp;</font></td>", &maxlen, &pos);
1883        ostrcatbig(&buf, "<td><input class=inputbox type=\"text\" name=\"end\" value=\"", &maxlen, &pos);
1884        ostrcatbig(&buf, buf1, &maxlen, &pos);
1885        ostrcatbig(&buf, "\" /></td></tr>", &maxlen, &pos);
1886        free(buf1); buf1 = NULL;
1887       
1888        free(buf2); buf2 = NULL;
1889       
1890        ostrcatbig(&buf, "</table><br><br><input class=button type=submit name=send value=\"Send\"></input>&nbsp;<input class=button type=reset name=reset value=\"Reset\"></input></form></center></body></html>", &maxlen, &pos);
1891       
1892        //ostrcatbig(&buf, param, &maxlen, &pos);
1893        return buf;
1894}
1895
1896char* webdelrectimer(char* param)
1897{
1898        char* buf = NULL;
1899        struct rectimer *node = NULL;
1900        //int maxlen = 0, pos = 0;
1901        //ostrcatbig(&buf, param, &maxlen, &pos);
1902        node = atoi(param);
1903        delrectimer(node, 1, 0);
1904        buf = webgetrectimer(NULL, 0);
1905       
1906        return buf;
1907}
1908
1909void putxmessage(struct stimerthread* timernode, char* captiontime, char* body)
1910{
1911        struct splitstr* ret1 = NULL;
1912        char* caption = NULL;
1913        int count1 = 0;
1914        int timeout = 0;
1915        ret1 = strsplit(captiontime, "\t", &count1);
1916        caption = ostrcat(caption, (&ret1[0])->part, 1, 0);
1917        timeout = atoi((&ret1[1])->part);
1918        textbox(caption, body, _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, NULL, 0, 600, 280, timeout, 0);
1919        free(caption); free(body); free(captiontime); free(ret1);
1920}
1921
1922void xmessage(char* filename)
1923{
1924        char* param=NULL, *param1 = NULL, *param2 = NULL, *param3 = NULL, *param4 = NULL;
1925        char* caption=NULL, *body=NULL;
1926        char* timeout=NULL;
1927        param4 = strstr(filename, "icon=");
1928        param3 = strstr(filename, "charset=");
1929        param2 = strstr(filename, "timeout=");
1930        param1 = strstr(filename, "caption=");
1931        param = strstr(filename, "body=");
1932
1933        if(param4 != NULL) {
1934                param4 = param4 - 1;
1935                *param4 = '\0';
1936                param4 = param4 + 5;
1937                *param4++ = '\0';
1938        }
1939        if(param3 != NULL) {
1940                param3 = param3 - 1;
1941                *param3 = '\0';
1942                param3 = param3 + 8;
1943                *param3++ = '\0';
1944        }
1945        if(param2 != NULL) {
1946                param2 = param2 - 1;
1947                *param2 = '\0';
1948                param2 = param2 + 8;
1949                *param2++ = '\0';
1950        }
1951        if(param1 != NULL) {
1952                param1 = param1 - 1;
1953                *param1 = '\0';
1954                param1 = param1 + 8;
1955                *param1++ = '\0';
1956        }
1957        if(param != NULL) {
1958                param = param - 1;
1959                *param = '\0';
1960                param = param + 5;
1961                *param++ = '\0';
1962                body=ostrcat(body, param, 1, 0);
1963        }
1964        else
1965                body=ostrcat(body, " ", 1, 0);
1966               
1967        if(param2 != NULL)
1968                timeout = ostrcat(timeout, param2, 1, 0);
1969        else
1970                timeout = ostrcat(timeout, "5", 1, 0);
1971               
1972        if(param1 != NULL)
1973                caption = ostrcat(caption, param1, 1, 0);
1974        else
1975                caption = ostrcat(caption, "XMESSAGE", 1, 0);
1976       
1977        caption = ostrcat(caption, "\t", 1, 0);
1978        caption = ostrcat(caption, timeout, 1, 0);
1979               
1980        //addtimer(&putxmessage, START, 1000, 1, (void*)caption, (void*)body, (void*)timeout);
1981        addtimer(&putxmessage, START, 1000, 1,(void*)caption, (void*)body, NULL);
1982        return;
1983}
1984
1985#endif
Note: See TracBrowser for help on using the repository browser.