source: titan/plugins/tithek/tithek.h @ 23572

Last change on this file since 23572 was 23572, checked in by obi, 11 years ago

fix codecpack check

File size: 66.8 KB
Line 
1#ifndef TITHEK_H
2#define TITHEK_H
3
4#define HTTPAUTH "aXBrLUdaRmg6RkhaVkJHaG56ZnZFaEZERlRHenVpZjU2NzZ6aGpHVFVHQk5Iam0="
5
6#define TITHEKPATH "/tmp/tithek"
7int tithekdownloadrun = 0;
8int tithekdownloadcount = 0;
9int tithekrun = 0;
10int tithekexit = 0;
11int tithekmovie4k = 0;
12int tithekkinox = 0;
13int titheksolarmovie = 0;
14int tithekmlehd = 0;
15
16//flag 0        - menu
17//flag 1        - menu pay hidden tithek_pay=0/1 0=hidden
18//flag 2        - http (default streamurl)
19//flag 3        - menu cover
20//flag 4        - youtube
21//flag 5        - rtl2now
22//flag 6        - superrtlnow
23//flag 7        - rtlnow
24//flag 8        - voxnow
25//flag 9        - youtube suche 10
26//flag 10       - youtube suche 25
27//flag 11       - youtube suche 50
28//flag 12       - myvideo
29//flag 13       - myvideo search 50
30//flag 14       - hoster putlocker/sockshare
31//flag 15       - hoster filenuke
32//flag 16       - superrtlnow pay
33//flag 17       - rtlnow pay
34//flag 18       - voxnow pay
35//flag 19       - rtl2now pay
36//flag 20       - hoster StreamCloud
37//flag 21       - kinox search
38//flag 22       - kinox hoster
39//flag 23       - kinox hoster serie
40//flag 24       - hoster flashx
41//flag 25       - hoster vidstream
42//flag 26       - hoster xvidstage
43//flag 27       - hoster nowvideo
44//flag 28       - solarmovie hoster
45//flag 29       - solarmovie search movie
46//flag 30       - solarmovie search serie
47//flag 31       - kinox search cast
48//flag 32       - kinox search cast results
49//flag 33       - movie4k search : serie > open seasons and list episode flag=40 > hoster listed flag=34
50//flag 34       - movie4k hoster de
51//flag 35       - movie4k hoster other
52//flag 36       - movie4k series de > open seasons and list episode flag=39 > hoster listed flag=34
53//flag 37       - movie4k series other > open seasons and list episode flag=39 > hoster listed flag=34
54//flag 38       - mlehd
55//flag 39   - movie4k_hoster_listed
56//flag 40   - movie4k_hoster_series
57//flag 41   - movie4k
58//flag 42   - xvideos
59
60//flag 50       - beeg
61//flag 66   - coming soon dummy
62//flag 1000 - menu pincode
63//flag 9999 - menu hidden codecpack
64
65struct tithek
66{
67        char* title;
68        char* link;
69        char* pic;
70        char* localname;
71        char* menutitle;       
72        int flag;
73        struct tithek* prev;
74        struct tithek* next;
75};
76struct tithek *tithek = NULL;
77
78
79void freetithekcontent(struct tithek* node)
80{
81        if(node == NULL) return;
82
83        free(node->title); node->title = NULL;
84        node->link = NULL;
85        node->pic = NULL;
86        node->localname = NULL;
87        node->menutitle = NULL;
88        node->flag = 0;
89}
90
91int addtithekcontent(struct tithek* node, char *line, int len, int count, int pay)
92{
93        int ret = 0, i = 0, skip = 0, hid = 0;
94        char* tmpstr = NULL, *flag = NULL, *cmd = NULL, *tmp = NULL;
95        if(node == NULL) return 1;
96
97        if(len > 0) tmpstr = malloc(len + 1);
98        if(tmpstr != NULL)
99        {
100                memcpy(tmpstr, line, len);
101                tmpstr[len] = '\0';
102
103                node->title = tmpstr;
104
105                while(tmpstr[0] != '\0')
106                {
107                        if(tmpstr[0] == '#')
108                        {
109                                tmpstr[0] = '\0';
110                                tmpstr++;
111                                switch(ret)
112                                {
113                                        case 0: node->link = tmpstr; break;
114                                        case 1: node->pic = tmpstr; break;
115                                        case 2: node->localname = tmpstr; break;
116                                        case 3: node->menutitle = tmpstr; break;
117                                        case 4: flag = tmpstr; break;
118                                }
119
120                                ret++;
121                        }
122                        else
123                                tmpstr++;
124                }
125        }
126
127        if(ret != 5)
128        {
129                if(count > 0)
130                {
131                        err("tithek line %d not ok (ret=%d)", count, ret);
132                }
133                else
134                {
135                        err("add tithek (ret=%d)", ret);
136                }
137                freetithekcontent(node);
138                return 1;
139        }
140
141        if(flag != NULL) node->flag = atoi(flag);
142       
143        hid = getconfigint("tithek_hid_xxx", NULL);
144        if(node->flag == 1000 && hid == 1)
145                skip = 1;
146        else if((node->flag == 9996 || node->flag == 9997 || node->flag == 9998 || node->flag == 9999) && !file_exist("/mnt/swapextensions/etc/.codecpack") && !file_exist("/var/swap/etc/.codecpack") && !file_exist("/var/etc/.codecpack"))
147                skip = 1;
148        else if(node->flag == 16 && pay == 0)
149                skip = 1;
150        else if(node->flag == 17 && pay == 0)
151                skip = 1;
152        else if(node->flag == 18 && pay == 0)
153                skip = 1;
154        else if(node->flag == 19 && pay == 0)
155                skip = 1;
156        else if(node->flag == 1 && pay == 0)
157                skip = 1;
158        else if(node->flag == 35 && pay == 0)
159                skip = 1;
160        else if(titheksolarmovie == 1 && node->flag == 9996)
161        {
162                cmd = ostrcat(cmd, "ww", 1, 0);
163                cmd = ostrcat(cmd, "w.sola", 1, 0);
164                cmd = ostrcat(cmd, "rmovi", 1, 0);
165                cmd = ostrcat(cmd, "e.", 1, 0);
166                cmd = ostrcat(cmd, "so", 1, 0);
167               
168                //if(system(cmd) != 0)
169                for(i = 0; i < 3; i++)
170                {
171                        free(tmp); tmp = NULL;
172                        tmp = gethttp(cmd, "/", 80, NULL, NULL, 5000, NULL, 0);
173                        if(tmp != NULL) break;
174                }
175                if(tmp == NULL)
176                        skip = 1;
177
178                titheksolarmovie = 0;
179        }
180        else if(tithekmovie4k == 1 && node->flag == 9997)
181        {
182                cmd = ostrcat(cmd, "ww", 1, 0);
183                cmd = ostrcat(cmd, "w.mov", 1, 0);
184                cmd = ostrcat(cmd, "ie4k", 1, 0);
185                cmd = ostrcat(cmd, ".", 1, 0);
186                cmd = ostrcat(cmd, "to", 1, 0);
187               
188                //if(system(cmd) != 0)
189                for(i = 0; i < 3; i++)
190                {
191                        free(tmp); tmp = NULL;
192                        tmp = gethttp(cmd, "/", 80, NULL, NULL, 5000, NULL, 0);
193                        if(tmp != NULL) break;
194                }
195                if(tmp == NULL)
196                        skip = 1;
197
198                tithekmovie4k = 0;
199        }               
200        else if(tithekmlehd == 1 && node->flag == 9998)
201        {
202                cmd = ostrcat(cmd, "ww", 1, 0);
203                cmd = ostrcat(cmd, "w.mle", 1, 0);
204                cmd = ostrcat(cmd, "-hd", 1, 0);
205                cmd = ostrcat(cmd, ".", 1, 0);
206                cmd = ostrcat(cmd, "se", 1, 0);
207               
208                //if(system(cmd) != 0)
209                for(i = 0; i < 3; i++)
210                {
211                        free(tmp); tmp = NULL;
212                        tmp = gethttp(cmd, "/", 80, NULL, NULL, 5000, NULL, 0);
213                        if(tmp != NULL) break;
214                }
215                if(tmp == NULL)
216                        skip = 1;
217
218                tithekmlehd = 0;
219        }
220        else if(tithekkinox == 1 && node->flag == 9999)
221        {
222                cmd = ostrcat(cmd, "kin", 1, 0);
223                cmd = ostrcat(cmd, "ox", 1, 0);
224                cmd = ostrcat(cmd, ".", 1, 0);
225                cmd = ostrcat(cmd, "to", 1, 0);
226               
227                //if(system(cmd) != 0)
228                for(i = 0; i < 3; i++)
229                {
230                        free(tmp); tmp = NULL;
231                        tmp = gethttp(cmd, "/", 80, NULL, NULL, 5000, NULL, 0);
232                        if(tmp != NULL) break;
233                }
234                if(tmp == NULL)
235                        skip = 1;
236
237                tithekkinox = 0;
238        }
239
240        if(skip == 1)
241        {
242                freetithekcontent(node);
243                return 1;
244        }
245
246        free(tmp); tmp = NULL;
247        free(cmd), cmd = NULL;
248               
249        return 0;
250}
251
252struct tithek* addtithek(char *line, int len, int count, struct tithek* last, int pay)
253{
254        //debug(1000, "in");
255        struct tithek *newnode = NULL, *prev = NULL, *node = NULL;
256        int ret = 0;
257
258        if(line == NULL) return NULL;
259
260        newnode = (struct tithek*)calloc(1, sizeof(struct tithek));
261        if(newnode == NULL)
262        {
263                err("no memory");
264                return NULL;
265        }
266
267        ret = addtithekcontent(newnode, line, len, count, pay);
268        if(ret == 1)
269        {
270                free(newnode);
271                return NULL;
272        }
273
274        node = tithek;
275
276        if(last == NULL)
277        {
278                while(node != NULL)
279                {
280                        prev = node;
281                        node = node->next;
282                }
283        }
284        else
285        {
286                prev = last;
287                node = last->next;
288        }
289
290        if(prev == NULL)
291                tithek = newnode;
292        else
293        {
294                prev->next = newnode;
295                newnode->prev = prev;
296        }
297        newnode->next = node;
298        if(node != NULL) node->prev = newnode;
299
300        //debug(1000, "out");
301        return newnode;
302}
303
304struct tithek* createtithek(struct tithek* update, char* title, char* link, char* pic, char* localname, char* menutitle, int flag)
305{
306        int pay = 0;
307        struct tithek* tnode = NULL;
308        char* tmpstr = NULL;
309       
310        pay = getconfigint("tithek_pay", NULL);
311
312        title = stringreplacechar(title, '#', ' ');
313        link = stringreplacechar(link, '#', ' ');
314        pic = stringreplacechar(pic, '#', ' ');
315        localname = stringreplacechar(localname, '#', ' ');
316        menutitle = stringreplacechar(menutitle, '#', ' ');
317       
318        tmpstr = ostrcat(tmpstr, title, 1, 0);
319        tmpstr = ostrcat(tmpstr, "#", 1, 0);
320        tmpstr = ostrcat(tmpstr, link, 1, 0);
321        tmpstr = ostrcat(tmpstr, "#", 1, 0);
322        tmpstr = ostrcat(tmpstr, pic, 1, 0);
323        tmpstr = ostrcat(tmpstr, "#", 1, 0);
324        tmpstr = ostrcat(tmpstr, localname, 1, 0);
325        tmpstr = ostrcat(tmpstr, "#", 1, 0);
326        tmpstr = ostrcat(tmpstr, menutitle, 1, 0);
327        tmpstr = ostrcat(tmpstr, "#", 1, 0);
328        tmpstr = ostrcat(tmpstr, oitoa(flag), 1, 1);
329
330        tmpstr = string_replace_all("\n", "", tmpstr, 1);
331        tmpstr = string_replace_all("\r", "", tmpstr, 1);
332
333        if(update != NULL)
334        {
335                freetithekcontent(update);
336                addtithekcontent(update, tmpstr, strlen(tmpstr), 1, pay);
337                tnode = update;
338        }
339        else
340                tnode = addtithek(tmpstr, strlen(tmpstr), 1, NULL, pay);
341
342        free(tmpstr);
343
344        return tnode;
345}
346
347int readtithek(const char* filename)
348{
349        debug(1000, "in");
350        FILE *fd = NULL;
351        char *fileline = NULL;
352        int linecount = 0, len = 0, pay = 0;
353        struct tithek* last = NULL, *tmplast = NULL;
354
355        fileline = malloc(MINMALLOC);
356        if(fileline == NULL)
357        {
358                err("no memory");
359                return 1;
360        }
361
362        fd = fopen(filename, "r");
363        if(fd == NULL)
364        {
365                perr("can't open %s", filename);
366                free(fileline);
367                return 1;
368        }
369
370        pay = getconfigint("tithek_pay", NULL);
371
372        while(fgets(fileline, MINMALLOC, fd) != NULL)
373        {
374                if(fileline[0] == '\n')
375                        continue;
376                len = strlen(fileline) - 1;
377                if(fileline[len] == '\n')
378                        fileline[len] = '\0';
379                if(fileline[len - 1] == '\r')
380                        fileline[len - 1] = '\0';
381
382                linecount++;
383
384                if(last == NULL) last = tmplast;
385                last = addtithek(fileline, len + 2, linecount, last, pay);
386                if(last != NULL) tmplast = last;
387        }
388
389        free(fileline);
390        fclose(fd);
391        return linecount;
392}
393
394int deltithek(char* link)
395{
396        debug(1000, "in");
397        int ret = 1;
398
399        struct tithek *node = tithek, *prev = tithek;
400
401        while(node != NULL)
402        {
403                if(ostrcmp(link, node->link) == 0)
404                {
405                        ret = 0;
406                        if(node == tithek)
407                        {
408                                tithek = node->next;
409                                if(tithek != NULL)
410                                        tithek->prev = NULL;
411                        }
412                        else
413                        {
414                                prev->next = node->next;
415                                if(node->next != NULL)
416                                        node->next->prev = prev;
417                        }
418
419                        freetithekcontent(node);
420
421                        free(node);
422                        node = NULL;
423
424                        break;
425                }
426
427                prev = node;
428                node = node->next;
429        }
430
431        debug(1000, "out");
432        return ret;
433}
434
435void freetithek()
436{
437        debug(1000, "in");
438        struct tithek *node = tithek, *prev = tithek;
439
440        while(node != NULL)
441        {
442                prev = node;
443                node = node->next;
444                if(prev != NULL)
445                        deltithek(prev->link);
446        }
447
448        debug(1000, "out");
449}
450
451void tithekdownloadthread(struct stimerthread* timernode, struct download* node, int flag)
452{
453        int defpic = 0;
454
455        tithekdownloadcount++;
456
457        if(node != NULL)
458        {
459                m_lock(&status.tithekmutex, 20);
460                if(file_exist(node->filename))
461                {
462                        m_unlock(&status.tithekmutex, 20);
463                        goto end;
464                }
465
466                FILE *fd; fd = fopen(node->filename, "w");
467                if(fd != NULL) fclose(fd);
468                m_unlock(&status.tithekmutex, 20);
469
470                gethttpreal(node->host, node->page, node->port, node->filename, node->auth, NULL, 0, NULL, NULL, node->timeout, 0);
471
472                if(tithekrun == 0)
473                        unlink(node->filename);
474                else
475                {
476                        //check file size
477                        /*
478                        off64_t checkpic = getfilesize(node->filename);
479                        if(checkpic < 200) defpic = 1;
480                        */
481
482                        //check file is gif or html
483                        if(defpic == 0)
484                        {
485                                char* tmp = NULL;
486                                tmp = readbintomem(node->filename, 3);
487                                if(ostrncmp("GIF", tmp, 3) == 0) defpic = 1; //gif
488                                if(ostrncmp("<", tmp, 1) == 0) defpic = 1; //html
489                                free(tmp); tmp = NULL;
490                        }
491
492                        if(defpic == 1)
493                        {
494                                m_lock(&status.tithekmutex, 20);
495                                unlink(node->filename);
496                                symlink("/var/usr/local/share/titan/plugins/tithek/default.jpg", node->filename);
497                                m_unlock(&status.tithekmutex, 20);
498                        }
499                }
500
501end:
502                free(node->host); node->host = NULL;
503                free(node->page); node->page = NULL;
504                free(node->filename); node->filename = NULL;
505                free(node->auth); node->auth = NULL;
506        }
507
508        free(node); node = NULL;
509
510        tithekdownloadcount--;
511        tithekdownloadrun = 1;
512}
513
514char* tithekdownload(char* link, char* localname, char* pw, int pic, int flag)
515{
516        int ret = 1, port = 80, timeout = 10000;
517        char* ip = NULL, *pos = NULL, *path = NULL;
518        char* tmpstr = NULL, *localfile = NULL;
519
520        if(link == NULL) return NULL;
521        if(ostrncmp("http://", link, 7)) return NULL;
522
523        ip = string_replace("http://", "", (char*)link, 0);
524        // tithek security
525        ip = string_replace_all("imageshack.us/md/up/grd/", "atemio.dyndns.tv/", ip, 1);
526
527        if(ip != NULL)
528                pos = strchr(ip, '/');
529        if(pos != NULL)
530        {
531                pos[0] = '\0';
532                path = pos + 1;
533        }
534
535        if(ostrstr(ip, ":") != NULL)
536        {
537                ip = oregex("http://(.*):.*", link);
538                port = atoi(oregex("http://.*:(.*)/.*", link));
539        }
540
541        tmpstr = ostrcat(path, NULL, 0, 0);
542
543        if(flag == 0)
544        {
545                localfile = ostrcat(TITHEKPATH, "/", 0, 0);
546                if(localname == NULL)
547                        localfile = ostrcat(localfile, basename(tmpstr), 1, 0);
548                else
549                        localfile = ostrcat(localfile, localname, 1, 0);
550        }
551        else
552        {
553                localfile = ostrcat(getconfig("rec_streampath", NULL), "/", 0, 0);
554                if(localname == NULL)
555                        localfile = ostrcat(localfile, basename(tmpstr), 1, 0);
556                else
557                        localfile = ostrcat(localfile, localname, 1, 0);
558        }
559
560/*
561        debug(99, "---------------------------------------");
562        debug(99, "link: %s", link);
563        debug(99, "localname: %s", localname);
564        debug(99, "---------------------------------------");
565        debug(99, "ip: %s", ip);
566        debug(99, "port: %d", port);
567        debug(99, "path: %s", path);
568        debug(99, "localfile: %s", localfile);
569//      debug(99, "pw: %s", pw);
570        debug(99, "---------------------------------------");
571*/
572        if(flag == 0)
573        {
574                if(localfile != NULL && !file_exist(localfile))
575                {
576                        if(pic == 1)
577                        {
578                                if(tithekdownloadcount >= 24) //start max 24 threads
579                                        gethttp(ip, path, port, localfile, pw, timeout, NULL, 0);
580                                else
581                                {
582                                        //dnode is freed in thread
583                                        struct download* dnode = calloc(1, sizeof(struct download));
584                                        if(dnode != NULL)
585                                        {
586                                                dnode->host = ostrcat(ip, NULL, 0, 0);
587                                                dnode->page = ostrcat(path, NULL, 0, 0);
588                                                dnode->port = port;
589                                                dnode->filename = ostrcat(localfile, NULL, 0, 0);
590                                                dnode->auth = ostrcat(pw, NULL, 0, 0);
591                                                dnode->connfd = -1;
592                                                dnode->ret = -1;
593                                                dnode->timeout = timeout;
594                                                addtimer(&tithekdownloadthread, START, 100, 1, (void*)dnode, NULL, NULL);
595                                        }
596                                }
597                        }
598                        else
599                                gethttp(ip, path, port, localfile, pw, timeout, NULL, 0);                       
600                }
601        }
602        else
603        {
604       
605                if(localfile != NULL && file_exist(localfile))
606                        ret = textbox(_("Message"), _("File exist, overwrite?"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
607
608                if(localfile != NULL && ret == 1)
609                        screendownload("Download", ip, path, port, localfile, pw, timeout, 0);
610        }
611
612        free(ip); ip = NULL;
613        free(tmpstr); tmpstr = NULL;
614
615        return localfile;
616}
617
618int createtithekplay(char* titheklink, struct skin* grid, struct skin* listbox, struct skin* countlabel, int flag)
619{
620        int gridbr = 0, posx = 0, count = 0, sumcount = 0, count1 = 0, pagecount = 0, skip = 0;
621        int localfile = 0;
622        struct skin* tmp = NULL;
623        char* tithekfile = NULL;
624        char* tmpstr = NULL;
625
626        if(!ostrncmp("http://", titheklink, 7))
627                tithekfile = tithekdownload(titheklink, NULL, HTTPAUTH, 0, 0);
628        else
629        {
630                tithekfile = ostrcat(titheklink, NULL, 0, 0);
631                localfile = 1;
632        }
633
634        delmarkedscreennodes(grid, 1);
635        freetithek();
636//      if(readtithek(tithekfile) != 0) return 1;
637        int linecount = readtithek(tithekfile);
638//      if(linecount == 0) return 1;
639       
640        struct tithek* titheknode = tithek;
641
642        int height = 500;
643        int width = 590;
644        int picheight = 480;
645        int picwidth = 570;
646        int zcount = 2;
647        int fontsize = 25;
648        int pcount = 2;
649
650        if(getconfigint("tithek_cover", NULL) == 0 || getconfigint("tithek_view", NULL) == 0)
651        {
652                if(linecount > 2)
653                {
654                        height = 280;
655                        width = 390;
656                        picheight = 230;
657                        picwidth = 370;
658                        zcount = 3;
659                        fontsize = 20;
660                        pcount = 6;
661                }
662         
663                if(linecount > 8)
664                {
665                        height = 180;
666                        width = 295;
667                        picheight = 130;
668                        picwidth = 270;
669                        zcount = 4;
670                        fontsize = 18;
671                        pcount = 12;
672                }
673
674                if(linecount > 19)
675                {
676                        height = 140;
677                        width = 235;
678                        picheight = 90;
679                        picwidth = 210;
680                        zcount = 5;
681                        fontsize = 16;
682                        pcount = 20;
683                }
684       
685                if(linecount > 25)
686                {
687                        height = 111;
688                        width = 196;
689                        picheight = 60;
690                        picwidth = 150;
691                        zcount = 6;
692                        fontsize = 14;
693                        pcount = 30;
694                }
695        }
696       
697        if((getconfigint("tithek_cover", NULL) == 1 && flag == 3) || (getconfigint("tithek_view", NULL) == 1 && flag != 3))
698        {
699                height = 500;
700                width = 590;
701                picheight = 480;
702                picwidth = 570;
703                zcount = 2;
704                fontsize = 25;
705                pcount = 2;
706        }
707
708        if((getconfigint("tithek_cover", NULL) == 2 && flag == 3) || (getconfigint("tithek_view", NULL) == 2 && flag != 3))
709        {
710                height = 280;
711                width = 390;
712                picheight = 230;
713                picwidth = 370;
714                zcount = 3;
715                fontsize = 20;
716                pcount = 6;
717        }
718
719        if((getconfigint("tithek_cover", NULL) == 3 && flag == 3) || (getconfigint("tithek_view", NULL) == 3 && flag != 3))
720        {
721                height = 180;
722                width = 295;
723                picheight = 130;
724                picwidth = 270;
725                zcount = 4;
726                fontsize = 18;
727                pcount = 12;
728        }
729
730        if((getconfigint("tithek_cover", NULL) == 4 && flag == 3) || (getconfigint("tithek_view", NULL) == 4 && flag != 3))
731        {
732                height = 140;
733                width = 235;
734                picheight = 90;
735                picwidth = 210;
736                zcount = 5;
737                fontsize = 16;
738                pcount = 20;
739        }
740
741        if((getconfigint("tithek_cover", NULL) == 5 && flag == 3) || (getconfigint("tithek_view", NULL) == 5 && flag != 3))
742        {
743                height = 111;
744                width = 196;
745                picheight = 60;
746                picwidth = 150;
747                zcount = 6;
748                fontsize = 14;
749                pcount = 30;
750        }
751
752        if(getconfigint("tithek_pic_ratio", NULL) == 1)
753        {
754                picwidth = 2;
755                picheight = 2;
756        }
757                       
758        while(titheknode != NULL)
759        {
760                tmp = addlistbox(grid, listbox, tmp, 1);
761                if(tmp != NULL)
762                {
763                        skip = 0;
764                        sumcount++;
765                        count++;
766                        count1++;
767                        if(gridbr == 0)
768                                tmp->type = GRIDBR;
769                        gridbr = 1;
770                        tmp->wrap = YES;
771
772                        tmp->picheight = picheight;
773                        tmp->picwidth = picwidth;
774                                                               
775                        tmp->fontsize = fontsize;
776                        tmp->height = height;
777                        tmp->width = width;
778                        tmp->prozwidth = 0;
779                        //tmp->bgcol = 0xffffff;
780                        tmp->bgspace = 1;
781                        tmp->vspace = 10;
782                        tmp->hspace = 10;
783                        tmp->posx = posx;
784                        //tmp->fontcol = 0x0000ff;
785                        tmp->halign = CENTER;
786                        tmp->valign = TEXTBOTTOM;
787                        changetext(tmp, titheknode->title);
788                        tmp->handle = (char*)titheknode;
789                        posx += tmp->width;
790                        if(count >= zcount)
791                        {
792                                count = 0;
793                                posx = 0;
794                                gridbr = 0;
795                        }
796                       
797                        if(count1 >= pcount)
798                        {
799                                count1 = 0;
800                                pagecount++;
801                                skip = 1;
802                        }
803                }
804                titheknode = titheknode->next;
805        }
806
807        if(skip == 0)
808                pagecount++;
809
810        tmpstr = oitoa(sumcount);
811
812        char* tmpstr1 = ostrcat(_("found"), NULL, 0, 0);
813        tmpstr1 = ostrcat(tmpstr1, " ", 1, 0);
814        tmpstr1 = ostrcat(tmpstr1, tmpstr, 1, 0);
815        free(tmpstr); tmpstr = NULL;
816        tmpstr1 = ostrcat(tmpstr1, " ", 1, 0);
817        tmpstr1 = ostrcat(tmpstr1, _("Results"), 1, 0);
818        changetext(countlabel, tmpstr1);
819        free(tmpstr1); tmpstr1 = NULL;
820
821        if(localfile == 0)
822                unlink(tithekfile);
823       
824        free(tithekfile); tithekfile = NULL;
825        return pagecount;
826}
827
828void removefav(char* title, char* link, char* pic, char* localname, char* menutitle, int flag)
829{
830        int count = 0, i = 0;
831        char* tmpstr = NULL, *tmpstr1 = NULL, *input = NULL;
832        struct splitstr* ret = NULL;
833
834        input = ostrcat(input, title, 1, 0);
835        input = ostrcat(input, "#", 1, 0);
836        input = ostrcat(input, link, 1, 0);
837        input = ostrcat(input, "#", 1, 0);
838        input = ostrcat(input, pic, 1, 0);
839        input = ostrcat(input, "#", 1, 0);
840        input = ostrcat(input, localname, 1, 0);
841        input = ostrcat(input, "#", 1, 0);
842        input = ostrcat(input, menutitle, 1, 0);
843        input = ostrcat(input, "#", 1, 0);
844        input = ostrcat(input, oitoa(flag), 1, 1);
845       
846        tmpstr = readfiletomem(getconfig("tithek_fav", NULL), 0);
847       
848        ret = strsplit(tmpstr, "\n", &count);
849
850        if(ret != NULL)
851        {
852                for(i = 0; i < count; i++)
853                {
854                        if(ostrcmp((ret[i]).part, input) != 0)
855                        {
856                                tmpstr1 = ostrcat(tmpstr1, ret[i].part, 1, 0);
857                                tmpstr1 = ostrcat(tmpstr1, "\n", 1, 0);
858                        }
859                        else
860                                printf("remove: %s\n", ret[i].part);
861                }
862        }
863
864        if(tmpstr1 != NULL && strlen(tmpstr1) > 0)
865                tmpstr1[strlen(tmpstr1) - 1] = '\0';
866
867        if(tmpstr1 == NULL)
868                writesys(getconfig("tithek_fav", NULL), "", 0);
869        else
870                writesys(getconfig("tithek_fav", NULL), tmpstr1, 0);
871
872        free(ret); ret = NULL;
873        free(tmpstr); tmpstr = NULL;
874        free(tmpstr1); tmpstr1 = NULL;
875        free(input); input = NULL;
876}
877
878void addfav(char* title, char* link, char* pic, char* localname, char* menutitle, int flag)
879{
880        int count = 0, i = 0;
881        char* tmpstr = NULL, *tmpstr1 = NULL, *input = NULL;
882        struct splitstr* ret = NULL;
883
884        input = ostrcat(input, title, 1, 0);
885        input = ostrcat(input, "#", 1, 0);
886        input = ostrcat(input, link, 1, 0);
887        input = ostrcat(input, "#", 1, 0);
888        input = ostrcat(input, pic, 1, 0);
889        input = ostrcat(input, "#", 1, 0);
890        input = ostrcat(input, localname, 1, 0);
891        input = ostrcat(input, "#", 1, 0);
892        input = ostrcat(input, menutitle, 1, 0);
893        input = ostrcat(input, "#", 1, 0);
894        input = ostrcat(input, oitoa(flag), 1, 1);
895        // tithek security
896        input = string_replace_all("http://atemio.dyndns.tv/", "http://imageshack.us/md/up/grd/", input, 1);
897       
898        tmpstr1 = ostrcat(tmpstr1, input, 1, 0);
899        tmpstr1 = ostrcat(tmpstr1, "\n", 1, 0);
900
901        tmpstr = readfiletomem(getconfig("tithek_fav", NULL), 0);
902       
903        ret = strsplit(tmpstr, "\n", &count);
904
905        if(ret != NULL)
906        {
907                for(i = 0; i < count; i++)
908                {
909                        if(ostrcmp((ret[i]).part, input) != 0)
910                        {
911                                tmpstr1 = ostrcat(tmpstr1, ret[i].part, 1, 0);
912                                tmpstr1 = ostrcat(tmpstr1, "\n", 1, 0);
913                        }
914                }
915        }
916
917        if(tmpstr1 != NULL && strlen(tmpstr1) > 0)
918                tmpstr1[strlen(tmpstr1) - 1] = '\0';
919
920        writesys(getconfig("tithek_fav", NULL), tmpstr1, 0);
921
922        free(ret); ret = NULL;
923        free(tmpstr); tmpstr = NULL;
924        free(tmpstr1); tmpstr1 = NULL;
925        free(input); input = NULL;
926}
927
928void cacheplay(char* link, char* filename, int flag)
929{
930        struct skin* load = getscreen("loadingproz");
931        struct skin* proztext = getscreennode(load, "proztext");
932
933        drawscreen(load, 0, 0);
934        int port = 80, count = 0, mcount = 0;
935        off64_t size = 0, msize = 0;
936        char* host = NULL, *pos = NULL, *path = NULL, *file = NULL, *tmpstr = NULL;
937        host = string_replace("http://", "", (char*)link, 0);
938
939        if(host != NULL)
940                pos = strchr(host, '/');
941        if(pos != NULL)
942        {
943                pos[0] = '\0';
944                path = pos + 1;
945        }
946
947        file = ostrcat(getconfig("rec_streampath", NULL), "/.cache.", 0, 0);
948        file = ostrcat(file, filename, 1, 0);
949
950        if(ostrstr(host, ":") != NULL)
951        {
952                host = oregex("http://(.*):.*", link);
953                port = atoi(oregex("http://.*:(.*)/.*", link));
954        }
955
956        debug(99, "---------------------------------------");
957        debug(99, "link: %s", link);
958        debug(99, "---------------------------------------");
959        debug(99, "host: %s", host);
960        debug(99, "port: %d", port);
961        debug(99, "path: %s", path);
962        debug(99, "local: %s", file);
963        debug(99, "---------------------------------------");
964       
965       
966        struct download* dnode = NULL;
967        dnode = calloc(1, sizeof(struct download));
968        if(dnode == NULL)
969        {
970                err("no mem");
971                return;
972        }               
973        dnode->host = host;
974        dnode->page = path;
975        dnode->port = port;
976        dnode->filename = file;
977        dnode->auth = NULL;
978        dnode->connfd = -1;
979        dnode->ret = -1;
980        dnode->timeout = 30000;
981       
982        addtimer(&gethttpstruct, START, 1000, 1, (void*)dnode, NULL, NULL);
983
984        if(flag == 1)
985        {
986                mcount = 120;
987                msize = 10485760;
988        }
989        else if(flag == 2)
990        {
991                mcount = 240;
992                msize = 20971520;
993        }
994        else if(flag == 3)
995        {
996                mcount = 360;
997                msize = 31457280;
998        }
999                       
1000        while(count < mcount || size >= msize)
1001        {
1002                sleep(1);
1003                count++;
1004                if(file_exist(file))
1005                        size = getfilesize(file);
1006
1007                int proz = 0;
1008                int proz1 = size * 100 / msize;
1009                debug(99, "size (%dprozent)", proz1);
1010
1011                int proz2 = count * 100 / mcount;
1012                debug(99, "time (%dprozent)", proz2);
1013               
1014                if(proz1 > proz2)
1015                        proz = proz1;
1016                else
1017                        proz = proz2;
1018
1019                debug(99, "cacheing...(%lldkb) (%dprozent)", size / 1024, proz);
1020
1021                if(size >= msize)
1022                        break;
1023                if(count >= mcount)
1024                        break;
1025               
1026                tmpstr = ostrcat(_("please wait..."), " (", 0, 0);
1027                tmpstr = ostrcat(tmpstr, oitoa(proz), 1, 1);
1028                tmpstr = ostrcat(tmpstr, "%)", 1, 0);
1029                clearscreen(load);
1030                changetext(proztext, tmpstr);
1031                drawscreen(load, 0, 0);
1032                free(tmpstr), tmpstr = NULL;
1033        }
1034
1035        screenplay(file, filename, 2, 0);
1036        sockclose(&dnode->connfd);
1037        free(dnode); dnode = NULL;
1038
1039        tmpstr = ostrcat(tmpstr, _("Remove Cachefile ?"), 1, 0);
1040        tmpstr = ostrcat(tmpstr, "\n\n", 1, 0);
1041        tmpstr = ostrcat(tmpstr, file, 1, 0);
1042       
1043        if(textbox(_("Message"), tmpstr, _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0) == 1)
1044        {
1045                unlink(file);
1046        }
1047        free(tmpstr), tmpstr = NULL;
1048        free(file), file = NULL;
1049        free(host), host = NULL;
1050}
1051
1052void backgrounddl(char* link, char* filename)
1053{
1054        int port = 80, ret = 0;
1055        char* host = NULL, *pos = NULL, *path = NULL, *file = NULL, *tmpstr = NULL;
1056        host = string_replace("http://", "", (char*)link, 0);
1057
1058        if(host != NULL)
1059                pos = strchr(host, '/');
1060        if(pos != NULL)
1061        {
1062                pos[0] = '\0';
1063                path = pos + 1;
1064        }
1065
1066        file = ostrcat(getconfig("rec_streampath", NULL), "/", 0, 0);
1067        file = ostrcat(file, filename, 1, 0);
1068
1069        if(ostrstr(host, ":") != NULL)
1070        {
1071                host = oregex("http://(.*):.*", link);
1072                port = atoi(oregex("http://.*:(.*)/.*", link));
1073        }
1074
1075        debug(99, "---------------------------------------");
1076        debug(99, "link: %s", link);
1077        debug(99, "---------------------------------------");
1078        debug(99, "host: %s", host);
1079        debug(99, "port: %d", port);
1080        debug(99, "path: %s", path);
1081        debug(99, "local: %s", file);
1082        debug(99, "---------------------------------------");
1083       
1084        ret = startbgdownload(host, path, port, file, NULL, 30000, 1);
1085        if(ret == 1)
1086                textbox(_("Message"), _("Can't start download.\nPlease try later."), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
1087                                       
1088        free(tmpstr), tmpstr = NULL;
1089        free(file), file = NULL;
1090        free(host), host = NULL;
1091}
1092       
1093void submenu(struct skin* listbox, struct skin* load, char* title)
1094{
1095printf("sub 11\n");
1096        int flag = 0;
1097        if(status.security == 1 || checkbox("WHITEBOX") == 1)
1098        {
1099printf("sub 22\n");
1100
1101                drawscreen(load, 0, 0);
1102                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
1103                char* tmpstr1 = NULL;
1104
1105                if(((struct tithek*)listbox->select->handle)->flag == 2)
1106                {
1107                        if(tmpstr != NULL) tmpstr1 = ostrcat(tmpstr, NULL, 0, 0);
1108                }                                               
1109                else if(((struct tithek*)listbox->select->handle)->flag == 4)
1110                {
1111                        if(tmpstr != NULL) tmpstr1 = youtube(tmpstr, NULL, NULL, 1);
1112                }                                               
1113                else if(((struct tithek*)listbox->select->handle)->flag == 5)
1114                {
1115                        if(tmpstr != NULL) tmpstr1 = rtl2now(tmpstr, "http://rtl2now.rtl2.de", "rtl2now", 1);
1116                }
1117                else if(((struct tithek*)listbox->select->handle)->flag == 6)
1118                {
1119                        if(tmpstr != NULL) tmpstr1 = rtl2now(tmpstr, "http://www.superrtlnow.de", "superrtlnow", 1);
1120                }
1121                else if(((struct tithek*)listbox->select->handle)->flag == 7)
1122                {
1123                        if(tmpstr != NULL) tmpstr1 = rtl2now(tmpstr, "http://rtl-now.rtl.de", "rtlnow", 1);
1124                }
1125                else if(((struct tithek*)listbox->select->handle)->flag == 8)
1126                {
1127                        if(tmpstr != NULL) tmpstr1 = rtl2now(tmpstr, "http://www.voxnow.de", "voxnow", 1);
1128                }
1129                else if(((struct tithek*)listbox->select->handle)->flag == 12)
1130                {
1131                        if(tmpstr != NULL) tmpstr1 = myvideo(tmpstr, NULL, NULL, 1);
1132                }
1133                else if(((struct tithek*)listbox->select->handle)->flag == 14)
1134                {
1135                        if(tmpstr != NULL) tmpstr1 = kinox(tmpstr, NULL, NULL, 1);
1136                }
1137                else if(((struct tithek*)listbox->select->handle)->flag == 15)
1138                {
1139                        if(tmpstr != NULL) tmpstr1 = kinox(tmpstr, NULL, NULL, 2);
1140                }
1141                else if(((struct tithek*)listbox->select->handle)->flag == 16)
1142                {
1143                        if(tmpstr != NULL) tmpstr1 = rtl2now(tmpstr, "http://www.superrtlnow.de", "superrtlnow", 1);
1144                }
1145                else if(((struct tithek*)listbox->select->handle)->flag == 17)
1146                {
1147                        if(tmpstr != NULL) tmpstr1 = rtl2now(tmpstr, "http://rtl-now.rtl.de", "rtlnow", 1);
1148                }
1149                else if(((struct tithek*)listbox->select->handle)->flag == 18)
1150                {
1151                        if(tmpstr != NULL) tmpstr1 = rtl2now(tmpstr, "http://www.voxnow.de", "voxnow", 1);
1152                }
1153                else if(((struct tithek*)listbox->select->handle)->flag == 19)
1154                {
1155                        if(tmpstr != NULL) tmpstr1 = rtl2now(tmpstr, "http://rtl2now.rtl2.de", "rtl2now", 1);
1156                }
1157                else if(((struct tithek*)listbox->select->handle)->flag == 20)
1158                {
1159                        if(tmpstr != NULL) tmpstr1 = kinox(tmpstr, NULL, NULL, 3);
1160                }
1161                else if(((struct tithek*)listbox->select->handle)->flag == 24)
1162                {
1163                        if(tmpstr != NULL) tmpstr1 = kinox(tmpstr, NULL, NULL, 4);
1164                }
1165                else if(((struct tithek*)listbox->select->handle)->flag == 25)
1166                {
1167                        if(tmpstr != NULL) tmpstr1 = kinox(tmpstr, NULL, NULL, 5);
1168                }
1169                else if(((struct tithek*)listbox->select->handle)->flag == 26)
1170                {
1171                        if(tmpstr != NULL) tmpstr1 = kinox(tmpstr, NULL, NULL, 6);
1172                }
1173                else if(((struct tithek*)listbox->select->handle)->flag == 27)
1174                {
1175                        if(tmpstr != NULL) tmpstr1 = kinox(tmpstr, NULL, NULL, 7);
1176                }
1177                else if(((struct tithek*)listbox->select->handle)->flag == 38)
1178                {
1179                        if(tmpstr != NULL) tmpstr1 = mlehd(tmpstr);
1180                }
1181                else if(((struct tithek*)listbox->select->handle)->flag == 41)
1182                {
1183               
1184                        if(tmpstr != NULL) tmpstr1 = movie4k(tmpstr);
1185                }
1186                else if(((struct tithek*)listbox->select->handle)->flag == 42)
1187                {
1188                        if(tmpstr != NULL) tmpstr1 = xvideos(tmpstr);
1189                }
1190                else if(((struct tithek*)listbox->select->handle)->flag == 50)
1191                {
1192                        if(tmpstr != NULL) tmpstr1 = beeg(tmpstr);
1193                }
1194
1195                free(tmpstr); tmpstr = NULL;
1196
1197                if(ostrcmp(title, "TiThek - Internet Radio") == 0)
1198                        flag = 4;
1199
1200                if(ostrstr(tmpstr1, "&") != NULL)
1201                {
1202                        printf("change streamurl from: %s\n", tmpstr1);
1203                        tmpstr1 = string_replace_all("&amp;", "&", tmpstr1, 1);
1204                        printf("change streamurl to: %s\n", tmpstr1);
1205                }
1206               
1207                if(tmpstr1 != NULL)
1208                {
1209                        char* filename = ostrcat(title, "_", 0, 0);
1210                        filename = ostrcat(filename, ((struct tithek*)listbox->select->handle)->title, 1, 0);
1211                        filename = ostrcat(filename, ".mp4", 1, 0);
1212                        filename = string_replace_all(" ", ".", filename, 1);
1213                        filename = string_replace_all("-", "_", filename, 1);
1214                        filename = string_replace_all("._.", "_", filename, 1);
1215                        debug(99, "filename: %s", filename);
1216                               
1217                        char* keyconf = NULL;
1218                        char* skintitle = "Choice Playback";
1219                        struct menulist* mlist = NULL, *mbox = NULL;
1220                       
1221                        addmenulist(&mlist, "Streaming Playback (default)", NULL, NULL, 0, 0);
1222                       
1223                        if(!ostrncmp("http://", tmpstr1, 7))
1224                        {
1225                                if(flag == 4)
1226                                {
1227                                        addmenulist(&mlist, "Streaming Playback Caching (0.5MB)", NULL, NULL, 0, 0);
1228                                        addmenulist(&mlist, "Streaming Playback Caching (1MB)", NULL, NULL, 0, 0);
1229                                }       
1230                                else if(!ostrncmp("http://", tmpstr1, 7))
1231                                {
1232//                                      addmenulist(&mlist, "Streaming Playback Caching (1MB)", NULL, NULL, 0, 0);
1233//                                      addmenulist(&mlist, "Streaming Playback Caching (2MB)", NULL, NULL, 0, 0);
1234//                                      addmenulist(&mlist, "Streaming Playback Caching (3MB)", NULL, NULL, 0, 0);
1235//                                      addmenulist(&mlist, "Streaming Playback Caching (4MB)", NULL, NULL, 0, 0);
1236                                        addmenulist(&mlist, "Streaming Playback Caching (5MB)", NULL, NULL, 0, 0);
1237                                        addmenulist(&mlist, "Streaming Playback Caching (7.5MB)", NULL, NULL, 0, 0);
1238                                        addmenulist(&mlist, "Streaming Playback Caching (10MB)", NULL, NULL, 0, 0);
1239                                        if(file_exist(getconfig("rec_streampath", NULL)))
1240                                        {
1241//                                              addmenulist(&mlist, "File Caching Playback (10MB / 120s)", NULL, NULL, 0, 0);
1242//                                              addmenulist(&mlist, "File Caching Playback (20MB / 240s)", NULL, NULL, 0, 0);
1243//                                              addmenulist(&mlist, "File Caching Playback (30MB / 360s)", NULL, NULL, 0, 0);
1244                                                if(status.expertmodus >= 11 || file_exist("/mnt/swapextensions/etc/.codecpack") || file_exist("/var/swap/etc/.codecpack") || file_exist("/var/etc/.codecpack"))
1245                                                {
1246                                                        addmenulist(&mlist, "Download Full File", NULL, NULL, 0, 0);
1247                                                        addmenulist(&mlist, "Download Full File (background)", NULL, NULL, 0, 0);
1248                                                }
1249                                        }
1250                                }
1251                        }
1252                        mbox = menulistbox(mlist, NULL, skintitle, NULL, NULL, 1, 0);
1253                        if(mbox != NULL) keyconf = mbox->name;
1254                        if(ostrcmp(keyconf, "Streaming Playback (default)") == 0)
1255                        {
1256                                addconfigtmp("playerbuffersize", "0");
1257                                screenplay(tmpstr1, filename, 2, flag);
1258                                delconfigtmp("playerbuffersize");
1259                        }
1260                        else if(ostrcmp(keyconf, "Streaming Playback Caching (0.5MB)") == 0)
1261                        {
1262                                addconfigtmp("playerbuffersize", "524288");
1263                                screenplay(tmpstr1, filename, 2, flag);
1264                                delconfigtmp("playerbuffersize");
1265                        }
1266                        else if(ostrcmp(keyconf, "Streaming Playback Caching (1MB)") == 0)
1267                        {
1268                                addconfigtmp("playerbuffersize", "1048576");
1269                                screenplay(tmpstr1, filename, 2, flag);
1270                                delconfigtmp("playerbuffersize");
1271                        }
1272                        else if(ostrcmp(keyconf, "Streaming Playback Caching (2MB)") == 0)
1273                        {
1274                                addconfigtmp("playerbuffersize", "2097152");
1275                                screenplay(tmpstr1, filename, 2, flag);
1276                                delconfigtmp("playerbuffersize");
1277                        }
1278                        else if(ostrcmp(keyconf, "Streaming Playback Caching (3MB)") == 0)
1279                        {
1280                                addconfigtmp("playerbuffersize", "3145728");
1281                                screenplay(tmpstr1, filename, 2, flag);
1282                                delconfigtmp("playerbuffersize");
1283                        }
1284                        else if(ostrcmp(keyconf, "Streaming Playback Caching (4MB)") == 0)
1285                        {
1286                                addconfigtmp("playerbuffersize", "4194304");
1287                                screenplay(tmpstr1, filename, 2, flag);
1288                                delconfigtmp("playerbuffersize");
1289                        }
1290                        else if(ostrcmp(keyconf, "Streaming Playback Caching (5MB)") == 0)
1291                        {
1292                                addconfigtmp("playerbuffersize", "5242880");
1293                                screenplay(tmpstr1, filename, 2, flag);
1294                                delconfigtmp("playerbuffersize");
1295                        }
1296                        else if(ostrcmp(keyconf, "Streaming Playback Caching (7.5MB)") == 0)
1297                        {
1298                                addconfigtmp("playerbuffersize", "7864320");
1299                                screenplay(tmpstr1, filename, 2, flag);
1300                                delconfigtmp("playerbuffersize");
1301                        }
1302                        else if(ostrcmp(keyconf, "Streaming Playback Caching (10MB)") == 0)
1303                        {
1304                                addconfigtmp("playerbuffersize", "10485760");
1305                                screenplay(tmpstr1, filename, 2, flag);
1306                                delconfigtmp("playerbuffersize");
1307                        }
1308                        else if(ostrcmp(keyconf, "File Caching Playback (10MB / 120s)") == 0)
1309                        {
1310                                cacheplay(tmpstr1, filename, 1);
1311                        }
1312                        else if(ostrcmp(keyconf, "File Caching Playback (20MB / 240s)") == 0)
1313                        {
1314                                cacheplay(tmpstr1, filename, 2);
1315                        }
1316                        else if(ostrcmp(keyconf, "File Caching Playback (30MB / 360s)") == 0)
1317                        {
1318                                cacheplay(tmpstr1, filename, 3);
1319                        }
1320                        else if(ostrcmp(keyconf, "Download Full File") == 0)
1321                        {
1322                                char* search = textinput("Search", filename);
1323                                if(search != NULL)
1324                                {       
1325                                        char* tmpstr2 = tithekdownload(tmpstr1, search, NULL, 0, 1);
1326//                                              drawscreen(grid, 0, 0);
1327                                        free(tmpstr2); tmpstr2 = NULL;
1328                               
1329                                        if(textbox(_("Message"), _("Start playback"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0) == 1)
1330                                        {
1331                                                tmpstr2 = ostrcat(getconfig("rec_streampath", NULL), "/", 0, 0);
1332                                                tmpstr2 = ostrcat(tmpstr2, search, 1, 0);
1333                                                screenplay(tmpstr2, filename, 2, flag);
1334                                                free(tmpstr2); tmpstr2 = NULL;
1335                                        }
1336                                }
1337                                free(search), search = NULL;
1338                        }
1339                        else if(ostrcmp(keyconf, "Download Full File (background)") == 0)
1340                        {
1341                                char* search = textinput("Search", filename);
1342                                if(search != NULL)
1343                                        backgrounddl(tmpstr1, search);
1344                                free(search), search = NULL;
1345                        }
1346                         
1347                        free(filename), filename = NULL;
1348                        freemenulist(mlist, 1); mlist = NULL;
1349                }
1350                else
1351                        textbox(_("Message"), _("Can't get Streamurl !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
1352               
1353                free(tmpstr1); tmpstr1 = NULL;
1354        }
1355        else
1356                textbox(_("Message"), _("Registration needed, please contact Atemio !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1000, 200, 0, 0);
1357}
1358
1359void screentithekplay(char* titheklink, char* title, int first)
1360{
1361        if(!file_exist("/mnt/swapextensions/player"))
1362                mkdir("/mnt/swapextensions/player", 0777);
1363
1364        char* disclaimer = NULL;
1365        disclaimer = ostrcat(disclaimer, "/mnt/swapextensions/player/tithek_disclaimer_accepted", 1, 0);
1366                               
1367        if(!file_exist(disclaimer))
1368        {
1369                char* tmpstr = gethttp("atemio.dyndns.tv", "/mediathek/disclaimer.txt", 80, NULL, HTTPAUTH, 5000, NULL, 0);
1370                if(textbox(_("TitanNit Tithek disclaimer"), _(tmpstr), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1100, 650, 0, 0) == 1)
1371                {
1372                        writesys(disclaimer, tmpstr, 0);                               
1373                        free(tmpstr), tmpstr = NULL;
1374                }
1375                else
1376                {
1377                        free(tmpstr), tmpstr = NULL;
1378                        free(disclaimer), disclaimer = NULL;
1379                        return;
1380                }
1381        }
1382        free(disclaimer), disclaimer = NULL;
1383
1384        int rcret = -1, oaktline = 1, oaktpage = -1, ogridcol = 0, pagecount = 0;
1385
1386        writesysint("/proc/sys/vm/drop_caches", 3, 0);
1387       
1388        if(first == 1)
1389        {
1390                delallfiles("/tmp/tithek", NULL);
1391                mkdir("/tmp/tithek", 777);
1392                if(status.mcaktiv == 0)
1393                {
1394                        rcret = servicestop(status.aktservice, 1, 1);
1395                        if(rcret == 1) return;
1396                }
1397        }
1398
1399        struct skin* grid = getscreen("titheklist");
1400        struct skin* listbox = getscreennode(grid, "listbox");
1401        struct skin* countlabel = getscreennode(grid, "countlabel");
1402        struct skin* countpage = getscreennode(grid, "countpage");
1403        struct skin* load = getscreen("loading");
1404        struct skin* tmp = NULL;
1405        char* tithekpic = NULL;
1406       
1407        drawscreen(load, 0, 0);
1408       
1409        if(titheklink == NULL) return;
1410       
1411        listbox->aktpage = -1;
1412        listbox->aktline = 1;
1413        listbox->gridcol = 0;
1414        listbox->select = NULL;
1415
1416        pagecount = createtithekplay(titheklink, grid, listbox, countlabel, first);
1417        if(pagecount == 0) return;
1418
1419        changetitle(grid, _(title));
1420        drawscreen(grid, 0, 0);
1421        addscreenrc(grid, listbox);
1422                               
1423        while(1)
1424        {
1425                changetitle(grid, _(title));
1426                changetext(countpage, NULL);
1427                if(listbox->select != NULL && listbox->select->handle != NULL)
1428                {
1429                        tmp = listbox->select;
1430                        while(tmp != NULL)
1431                        {
1432
1433                                if(tmp->pagecount != listbox->aktpage) break;
1434
1435                                char* tmpstr = ostrcat(_("Page"), NULL, 0, 0);
1436                                tmpstr = ostrcat(tmpstr, " ( ", 1, 0);
1437                                tmpstr = ostrcat(tmpstr, oitoa(tmp->pagecount), 1, 1);
1438                                tmpstr = ostrcat(tmpstr, " / ", 1, 0);
1439                                tmpstr = ostrcat(tmpstr, oitoa(pagecount), 1, 1);
1440                                tmpstr = ostrcat(tmpstr, " )", 1, 0);
1441                                changetext(countpage, tmpstr);
1442                                free(tmpstr); tmpstr = NULL;
1443       
1444                                if(tmp->handle != NULL)
1445                                {
1446                                        tithekpic = tithekdownload(((struct tithek*)tmp->handle)->pic, ((struct tithek*)tmp->handle)->localname, "aXBrLUdaRmg6RkhaVkJHaG56ZnZFaEZERlRHenVpZjU2NzZ6aGpHVFVHQk5Iam0=", 1, 0);
1447
1448                                        /* not working with thread download
1449                                        off64_t checkpic = getfilesize(tithekpic);
1450                       
1451                                        if(checkpic < 1000)
1452                                        {
1453                                                free(tithekpic); tithekpic = NULL;
1454                                                tithekpic = ostrcat("/var/usr/local/share/titan/plugins/tithek/default.jpg", NULL, 0, 0);
1455                                        }
1456                                        */
1457                       
1458                                        changepic(tmp, tithekpic);
1459                                        free(tithekpic); tithekpic = NULL;
1460                                }
1461                                tmp = tmp->prev;
1462                        }
1463                        tmp = listbox->select;
1464                        if(tmp != NULL) tmp = tmp->next;
1465                        while(tmp != NULL)
1466                        {
1467                                if(tmp->pagecount != listbox->aktpage) break;
1468                                if(tmp->handle != NULL)
1469                                {
1470                                        tithekpic = tithekdownload(((struct tithek*)tmp->handle)->pic, ((struct tithek*)tmp->handle)->localname, "aXBrLUdaRmg6RkhaVkJHaG56ZnZFaEZERlRHenVpZjU2NzZ6aGpHVFVHQk5Iam0=", 1, 0);
1471
1472                                        /* not working with thread download
1473                                        off64_t checkpic = getfilesize(tithekpic);
1474
1475                                        if(checkpic < 1000)
1476                                        {
1477                                                free(tithekpic); tithekpic = NULL;
1478                                                tithekpic = ostrcat("/var/usr/local/share/titan/plugins/tithek/default.jpg", NULL, 0, 0);
1479                                        }
1480                                        */
1481
1482                                        changepic(tmp, tithekpic);
1483                                        free(tithekpic); tithekpic = NULL;
1484                                }
1485                                tmp = tmp->next;
1486                        }
1487                }
1488               
1489                int count = getfilecount(TITHEKPATH);
1490                if(count > 500)
1491                        delallfiles(TITHEKPATH, ".jpg");
1492
1493                drawscreen(grid, 0, 0);
1494waitrcstart:
1495                rcret = waitrc(grid, 2000, 2);
1496
1497                if(rcret == RCTIMEOUT)
1498                {
1499                        if(tithekdownloadrun == 1)
1500                        {
1501                                tithekdownloadrun = 0;
1502                                drawscreen(grid, 0, 0);
1503                        }
1504                        goto waitrcstart;
1505                }
1506
1507                if(rcret == getrcconfigint("rcblue", NULL))
1508                {
1509                        tithekexit = 1;
1510                        break;
1511                }
1512
1513                if(rcret == getrcconfigint("rcexit", NULL)) break;
1514                if(rcret == getrcconfigint("rcmenu", NULL))
1515                {
1516                        screentithek_settings();
1517
1518                        pagecount = createtithekplay(titheklink, grid, listbox, countlabel, first);
1519                        if(pagecount == 0 || tithekexit == 1) break;
1520
1521                        listbox->aktpage = -1;
1522                        listbox->aktline = 1;
1523                        listbox->gridcol = 1;
1524                        addscreenrc(grid, listbox);
1525                        drawscreen(grid, 0, 0);
1526                }
1527               
1528                if(rcret == getrcconfigint("rcred", NULL))
1529                {
1530                        if(listbox->select != NULL && listbox->select->handle != NULL)
1531                        {
1532
1533                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->title, NULL, 0, 0);
1534                                debug(99, "tmpstr: %s", tmpstr);
1535                                tmpstr = string_replace("-1 (de)", "", tmpstr, 1);
1536                                tmpstr = string_replace("-1 (en)", "", tmpstr, 1);
1537                                tmpstr = string_replace("-1 (\?\?)", "", tmpstr, 1);
1538                                tmpstr = string_replace("-2 (de)", "", tmpstr, 1);
1539                                tmpstr = string_replace("-2 (en)", "", tmpstr, 1);
1540                                tmpstr = string_replace("-2 (\?\?)", "", tmpstr, 1);
1541                                tmpstr = string_replace("-3 (de)", "", tmpstr, 1);
1542                                tmpstr = string_replace("-3 (en)", "", tmpstr, 1);
1543                                tmpstr = string_replace("-3 (\?\?)", "", tmpstr, 1);
1544                                tmpstr = string_replace(" (de)", "", tmpstr, 1);
1545                                tmpstr = string_replace(" (en)", "", tmpstr, 1);
1546                                tmpstr = string_replace(" (\?\?)", "", tmpstr, 1);
1547                                tmpstr = string_replace_all("_", " ", tmpstr, 1);
1548                                tmpstr = string_replace_all("-", " ", tmpstr, 1);
1549                                tmpstr = string_replace_all(".", " ", tmpstr, 1);                               
1550                                debug(99, "tmpstr: %s", tmpstr);
1551
1552                                int check = playrcred(tmpstr, NULL, 1, 0, 99);
1553                                if(check == 2)
1554                                {
1555                                        if(kinox_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, "KinoX - Search", tmpstr, 0) == 0)
1556                                        {
1557                                                oaktpage = listbox->aktpage;
1558                                                oaktline = listbox->aktline;
1559                                                ogridcol = listbox->gridcol;
1560                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
1561                                                char* tmpstr1 = ostrcat("KinoX - Search", " - ", 0, 0);
1562                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
1563                                                screentithekplay(tmpstr, tmpstr2, 0);
1564                                                free(tmpstr); tmpstr = NULL;
1565                                                free(tmpstr2); tmpstr2 = NULL;
1566                       
1567                                                pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 0);
1568                                                if(pagecount == 0 || tithekexit == 1) break;
1569
1570                                                listbox->aktpage = oaktpage;
1571                                                listbox->aktline = oaktline;
1572                                                listbox->gridcol = ogridcol;
1573                                                addscreenrc(grid, listbox);
1574                                        }
1575                                }
1576                                else if(check == 3)
1577                                {
1578                                        if(solarmovie_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, "SolarMovies - Movie - Search", tmpstr, 0) == 0)
1579                                        {
1580                                                oaktpage = listbox->aktpage;
1581                                                oaktline = listbox->aktline;
1582                                                ogridcol = listbox->gridcol;
1583                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
1584                                                char* tmpstr1 = ostrcat("SolarMovies - Movie - Search", " - ", 0, 0);
1585                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
1586                                                screentithekplay(tmpstr, tmpstr2, 0);
1587                                                free(tmpstr); tmpstr = NULL;
1588                                                free(tmpstr2); tmpstr2 = NULL;
1589                       
1590                                                pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 0);
1591                                                if(pagecount == 0 || tithekexit == 1) break;
1592
1593                                                listbox->aktpage = oaktpage;
1594                                                listbox->aktline = oaktline;
1595                                                listbox->gridcol = ogridcol;
1596                                                addscreenrc(grid, listbox);
1597                                        }
1598                                }
1599                                else if(check == 4)
1600                                {
1601                                        if(solarmovie_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, "SolarMovies - Tv - Search", tmpstr, 1) == 0)
1602                                        {
1603                                                oaktpage = listbox->aktpage;
1604                                                oaktline = listbox->aktline;
1605                                                ogridcol = listbox->gridcol;
1606                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
1607                                                char* tmpstr1 = ostrcat("SolarMovies - Tv - Search", " - ", 0, 0);
1608                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
1609                                                screentithekplay(tmpstr, tmpstr2, 0);
1610                                                free(tmpstr); tmpstr = NULL;
1611                                                free(tmpstr2); tmpstr2 = NULL;
1612                       
1613                                                pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 0);
1614                                                if(pagecount == 0 || tithekexit == 1) break;
1615
1616                                                listbox->aktpage = oaktpage;
1617                                                listbox->aktline = oaktline;
1618                                                listbox->gridcol = ogridcol;
1619                                                addscreenrc(grid, listbox);
1620                                        }
1621                                }
1622                                else if(check == 5)
1623                                {
1624                                        if(youtube_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, "Youtube - Search", tmpstr) == 0)
1625                                        {
1626                                                oaktpage = listbox->aktpage;
1627                                                oaktline = listbox->aktline;
1628                                                ogridcol = listbox->gridcol;
1629                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
1630                                                char* tmpstr1 = ostrcat("Youtube - Search", " - ", 0, 0);
1631                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
1632                                                screentithekplay(tmpstr, tmpstr2, 0);
1633                                                free(tmpstr); tmpstr = NULL;
1634                                                free(tmpstr2); tmpstr2 = NULL;
1635                       
1636                                                pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 0);
1637                                                if(pagecount == 0 || tithekexit == 1) break;
1638
1639                                                listbox->aktpage = oaktpage;
1640                                                listbox->aktline = oaktline;
1641                                                listbox->gridcol = ogridcol;
1642                                                addscreenrc(grid, listbox);
1643                                        }
1644                                }
1645                                else if(check == 7)
1646                                {
1647                                        if(movie4k_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, "KinoX - Search", tmpstr, 0) == 0)
1648                                        {
1649                                                oaktpage = listbox->aktpage;
1650                                                oaktline = listbox->aktline;
1651                                                ogridcol = listbox->gridcol;
1652                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
1653                                                char* tmpstr1 = ostrcat("Movie4k - Search", " - ", 0, 0);
1654                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
1655                                                screentithekplay(tmpstr, tmpstr2, 0);
1656                                                free(tmpstr); tmpstr = NULL;
1657                                                free(tmpstr2); tmpstr2 = NULL;
1658                       
1659                                                pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 0);
1660                                                if(pagecount == 0 || tithekexit == 1) break;
1661
1662                                                listbox->aktpage = oaktpage;
1663                                                listbox->aktline = oaktline;
1664                                                listbox->gridcol = ogridcol;
1665                                                addscreenrc(grid, listbox);
1666                                        }
1667                                }
1668                                else if((((struct tithek*)listbox->select->handle)->flag == 13))
1669                                {
1670                                        if(myvideo_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, "MyVideo - Search", tmpstr) == 0)
1671                                        {
1672                                                oaktpage = listbox->aktpage;
1673                                                oaktline = listbox->aktline;
1674                                                ogridcol = listbox->gridcol;
1675                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
1676                                                char* tmpstr1 = ostrcat("MyVideo - Search", " - ", 0, 0);
1677                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
1678                                                screentithekplay(tmpstr, tmpstr2, 0);
1679                                                free(tmpstr); tmpstr = NULL;
1680                                                free(tmpstr2); tmpstr2 = NULL;
1681                       
1682                                                pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 0);
1683                                                if(pagecount == 0 || tithekexit == 1) break;
1684
1685                                                listbox->aktpage = oaktpage;
1686                                                listbox->aktline = oaktline;
1687                                                listbox->gridcol = ogridcol;
1688                                                addscreenrc(grid, listbox);
1689                                        }
1690                                }
1691
1692                                free(tmpstr), tmpstr = NULL;
1693                        }
1694                }
1695                else if(rcret == getrcconfigint("rcok", NULL))
1696                {
1697                        if(listbox->select != NULL && listbox->select->handle != NULL)
1698                        {
1699                                clearscreen(grid);
1700
1701                                if((((struct tithek*)listbox->select->handle)->flag == 2) || (((struct tithek*)listbox->select->handle)->flag == 4) || (((struct tithek*)listbox->select->handle)->flag == 5) || (((struct tithek*)listbox->select->handle)->flag == 6) || (((struct tithek*)listbox->select->handle)->flag == 7) || (((struct tithek*)listbox->select->handle)->flag == 8) || (((struct tithek*)listbox->select->handle)->flag == 12) || (((struct tithek*)listbox->select->handle)->flag == 14) || (((struct tithek*)listbox->select->handle)->flag == 15) || (((struct tithek*)listbox->select->handle)->flag == 16) || (((struct tithek*)listbox->select->handle)->flag == 17) || (((struct tithek*)listbox->select->handle)->flag == 18) || (((struct tithek*)listbox->select->handle)->flag == 19) || (((struct tithek*)listbox->select->handle)->flag == 20) || (((struct tithek*)listbox->select->handle)->flag == 24) || (((struct tithek*)listbox->select->handle)->flag == 25) || (((struct tithek*)listbox->select->handle)->flag == 26) || (((struct tithek*)listbox->select->handle)->flag == 27) || (((struct tithek*)listbox->select->handle)->flag == 38) || (((struct tithek*)listbox->select->handle)->flag == 42) || (((struct tithek*)listbox->select->handle)->flag == 50) || (((struct tithek*)listbox->select->handle)->flag == 41))
1702                                {
1703                                        submenu(listbox, load, title);
1704                                        drawscreen(grid, 0, 0);
1705                                }
1706                                else if((((struct tithek*)listbox->select->handle)->flag == 9) || (((struct tithek*)listbox->select->handle)->flag == 10) || (((struct tithek*)listbox->select->handle)->flag == 11))
1707                                {
1708                                        if(youtube_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title, NULL) == 0)
1709                                        {
1710                                                oaktpage = listbox->aktpage;
1711                                                oaktline = listbox->aktline;
1712                                                ogridcol = listbox->gridcol;
1713                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
1714                                                char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0);
1715                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
1716                                                screentithekplay(tmpstr, tmpstr2, 0);
1717                                                free(tmpstr); tmpstr = NULL;
1718                                                free(tmpstr2); tmpstr2 = NULL;
1719                       
1720                                                pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 0);
1721                                                if(pagecount == 0 || tithekexit == 1) break;
1722
1723                                                listbox->aktpage = oaktpage;
1724                                                listbox->aktline = oaktline;
1725                                                listbox->gridcol = ogridcol;
1726                                                addscreenrc(grid, listbox);
1727                                        }
1728                                }
1729                                else if((((struct tithek*)listbox->select->handle)->flag == 13))
1730                                {
1731                                        if(myvideo_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title, NULL) == 0)
1732                                        {
1733                                                oaktpage = listbox->aktpage;
1734                                                oaktline = listbox->aktline;
1735                                                ogridcol = listbox->gridcol;
1736                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
1737                                                char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0);
1738                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
1739                                                screentithekplay(tmpstr, tmpstr2, 0);
1740                                                free(tmpstr); tmpstr = NULL;
1741                                                free(tmpstr2); tmpstr2 = NULL;
1742                       
1743                                                pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 0);
1744                                                if(pagecount == 0 || tithekexit == 1) break;
1745
1746                                                listbox->aktpage = oaktpage;
1747                                                listbox->aktline = oaktline;
1748                                                listbox->gridcol = ogridcol;
1749                                                addscreenrc(grid, listbox);
1750                                        }
1751                                }
1752                                else if((((struct tithek*)listbox->select->handle)->flag == 21))
1753                                {
1754                                        if(kinox_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title, NULL, 0) == 0)
1755                                        {
1756                                                oaktpage = listbox->aktpage;
1757                                                oaktline = listbox->aktline;
1758                                                ogridcol = listbox->gridcol;
1759                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
1760                                                char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0);
1761                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
1762                                                screentithekplay(tmpstr, tmpstr2, 0);
1763                                                free(tmpstr); tmpstr = NULL;
1764                                                free(tmpstr2); tmpstr2 = NULL;
1765
1766                                                pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 0);
1767                                                if(pagecount == 0 || tithekexit == 1) break;
1768
1769                                                listbox->aktpage = oaktpage;
1770                                                listbox->aktline = oaktline;
1771                                                listbox->gridcol = ogridcol;
1772                                                addscreenrc(grid, listbox);
1773                                        }
1774                                }
1775                                else if((((struct tithek*)listbox->select->handle)->flag == 33))
1776                                {
1777                                        if(movie4k_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title, NULL, 0) == 0)
1778                                        {
1779                                                oaktpage = listbox->aktpage;
1780                                                oaktline = listbox->aktline;
1781                                                ogridcol = listbox->gridcol;
1782                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
1783                                                char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0);
1784                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
1785                                                screentithekplay(tmpstr, tmpstr2, 0);
1786                                                free(tmpstr); tmpstr = NULL;
1787                                                free(tmpstr2); tmpstr2 = NULL;
1788
1789                                                pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 0);
1790                                                if(pagecount == 0 || tithekexit == 1) break;
1791
1792                                                listbox->aktpage = oaktpage;
1793                                                listbox->aktline = oaktline;
1794                                                listbox->gridcol = ogridcol;
1795                                                addscreenrc(grid, listbox);
1796                                        }
1797                                }                               
1798                                else if(((struct tithek*)listbox->select->handle)->flag == 29)
1799                                {
1800                                        if(solarmovie_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title, NULL, 0) == 0)
1801                                        {
1802                                                oaktpage = listbox->aktpage;
1803                                                oaktline = listbox->aktline;
1804                                                ogridcol = listbox->gridcol;
1805                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
1806                                                char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0);
1807                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
1808                                                screentithekplay(tmpstr, tmpstr2, 0);
1809                                                free(tmpstr); tmpstr = NULL;
1810                                                free(tmpstr2); tmpstr2 = NULL;
1811
1812                                                pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 0);
1813                                                if(pagecount == 0 || tithekexit == 1) break;
1814
1815                                                listbox->aktpage = oaktpage;
1816                                                listbox->aktline = oaktline;
1817                                                listbox->gridcol = ogridcol;
1818                                                addscreenrc(grid, listbox);
1819                                        }
1820                                }
1821                                else if(((struct tithek*)listbox->select->handle)->flag == 30)
1822                                {
1823                                        if(solarmovie_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title, NULL, 1) == 0)
1824                                        {
1825                                                oaktpage = listbox->aktpage;
1826                                                oaktline = listbox->aktline;
1827                                                ogridcol = listbox->gridcol;
1828                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
1829                                                char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0);
1830                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
1831                                                screentithekplay(tmpstr, tmpstr2, 0);
1832                                                free(tmpstr); tmpstr = NULL;
1833                                                free(tmpstr2); tmpstr2 = NULL;
1834
1835                                                pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 0);
1836                                                if(pagecount == 0 || tithekexit == 1) break;
1837
1838                                                listbox->aktpage = oaktpage;
1839                                                listbox->aktline = oaktline;
1840                                                listbox->gridcol = ogridcol;
1841                                                addscreenrc(grid, listbox);
1842                                        }
1843                                }
1844                                else if((((struct tithek*)listbox->select->handle)->flag == 31))
1845                                {
1846                                        if(kinox_search_cast(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title, NULL) == 0)
1847                                        {
1848                                                oaktpage = listbox->aktpage;
1849                                                oaktline = listbox->aktline;
1850                                                ogridcol = listbox->gridcol;
1851                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
1852                                                char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0);
1853                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
1854                                                screentithekplay(tmpstr, tmpstr2, 0);
1855                                                free(tmpstr); tmpstr = NULL;
1856                                                free(tmpstr2); tmpstr2 = NULL;
1857
1858                                                pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 0);
1859                                                if(pagecount == 0 || tithekexit == 1) break;
1860
1861                                                listbox->aktpage = oaktpage;
1862                                                listbox->aktline = oaktline;
1863                                                listbox->gridcol = ogridcol;
1864                                                addscreenrc(grid, listbox);
1865                                        }
1866                                }
1867                                else if((((struct tithek*)listbox->select->handle)->flag == 32))
1868                                {
1869                                        if(kinox_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title, NULL, 1) == 0)
1870                                        {
1871                                                oaktpage = listbox->aktpage;
1872                                                oaktline = listbox->aktline;
1873                                                ogridcol = listbox->gridcol;
1874                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
1875                                                char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0);
1876                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
1877                                                screentithekplay(tmpstr, tmpstr2, 0);
1878                                                free(tmpstr); tmpstr = NULL;
1879                                                free(tmpstr2); tmpstr2 = NULL;
1880
1881                                                pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 0);
1882                                                if(pagecount == 0 || tithekexit == 1) break;
1883
1884                                                listbox->aktpage = oaktpage;
1885                                                listbox->aktline = oaktline;
1886                                                listbox->gridcol = ogridcol;
1887                                                addscreenrc(grid, listbox);
1888                                        }
1889                                }
1890                                else if((((struct tithek*)listbox->select->handle)->flag == 33))
1891                                {
1892                                        if(movie4k_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title, NULL, 1) == 0)
1893                                        {
1894                                                oaktpage = listbox->aktpage;
1895                                                oaktline = listbox->aktline;
1896                                                ogridcol = listbox->gridcol;
1897                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
1898                                                char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0);
1899                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
1900                                                screentithekplay(tmpstr, tmpstr2, 0);
1901                                                free(tmpstr); tmpstr = NULL;
1902                                                free(tmpstr2); tmpstr2 = NULL;
1903
1904                                                pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 3);
1905                                                if(pagecount == 0 || tithekexit == 1) break;
1906
1907                                                listbox->aktpage = oaktpage;
1908                                                listbox->aktline = oaktline;
1909                                                listbox->gridcol = ogridcol;
1910                                                addscreenrc(grid, listbox);
1911                                        }
1912                                }
1913                                else if((((struct tithek*)listbox->select->handle)->flag == 34) || (((struct tithek*)listbox->select->handle)->flag == 35))
1914                                {
1915                                        if(movie4k_hoster(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title) == 0)
1916                                        {
1917                                                oaktpage = listbox->aktpage;
1918                                                oaktline = listbox->aktline;
1919                                                ogridcol = listbox->gridcol;
1920                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
1921                                                char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0);
1922                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
1923                                                screentithekplay(tmpstr, tmpstr2, 0);
1924                                                free(tmpstr); tmpstr = NULL;
1925                                                free(tmpstr2); tmpstr2 = NULL;
1926
1927                                                pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 0);
1928                                                if(pagecount == 0 || tithekexit == 1) break;
1929
1930                                                listbox->aktpage = oaktpage;
1931                                                listbox->aktline = oaktline;
1932                                                listbox->gridcol = ogridcol;
1933                                                addscreenrc(grid, listbox);
1934                                        }
1935                                }
1936                                else if((((struct tithek*)listbox->select->handle)->flag == 22))
1937                                {
1938                                        if(kinox_hoster(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title) == 0)
1939                                        {
1940                                                oaktpage = listbox->aktpage;
1941                                                oaktline = listbox->aktline;
1942                                                ogridcol = listbox->gridcol;
1943                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
1944                                                char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0);
1945                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
1946                                                screentithekplay(tmpstr, tmpstr2, 0);
1947                                                free(tmpstr); tmpstr = NULL;
1948                                                free(tmpstr2); tmpstr2 = NULL;
1949
1950                                                pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 3);
1951                                                if(pagecount == 0 || tithekexit == 1) break;
1952
1953                                                listbox->aktpage = oaktpage;
1954                                                listbox->aktline = oaktline;
1955                                                listbox->gridcol = ogridcol;
1956                                                addscreenrc(grid, listbox);
1957                                        }
1958                                }
1959                                else if((((struct tithek*)listbox->select->handle)->flag == 28))
1960                                {
1961                                        if(solarmovie_hoster(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title) == 0)
1962                                        {
1963                                                oaktpage = listbox->aktpage;
1964                                                oaktline = listbox->aktline;
1965                                                ogridcol = listbox->gridcol;
1966                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
1967                                                char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0);
1968                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
1969                                                screentithekplay(tmpstr, tmpstr2, 0);
1970                                                free(tmpstr); tmpstr = NULL;
1971                                                free(tmpstr2); tmpstr2 = NULL;
1972                       
1973                                                pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 3);
1974                                                if(pagecount == 0 || tithekexit == 1) break;
1975
1976                                                listbox->aktpage = oaktpage;
1977                                                listbox->aktline = oaktline;
1978                                                listbox->gridcol = ogridcol;
1979                                                addscreenrc(grid, listbox);
1980                                        }
1981                                }
1982                                else if((((struct tithek*)listbox->select->handle)->flag == 23))
1983                                {
1984                                        if(kinox_hoster_series(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title) == 0)
1985                                        {
1986                                                oaktpage = listbox->aktpage;
1987                                                oaktline = listbox->aktline;
1988                                                ogridcol = listbox->gridcol;
1989                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
1990                                                char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0);
1991                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
1992                                                screentithekplay(tmpstr, tmpstr2, 0);
1993                                                free(tmpstr); tmpstr = NULL;
1994                                                free(tmpstr2); tmpstr2 = NULL;
1995                       
1996                                                pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 0);
1997                                                if(pagecount == 0 || tithekexit == 1) break;
1998
1999                                                listbox->aktpage = oaktpage;
2000                                                listbox->aktline = oaktline;
2001                                                listbox->gridcol = ogridcol;
2002                                                addscreenrc(grid, listbox);
2003                                        }
2004                                }
2005                                else if((((struct tithek*)listbox->select->handle)->flag == 36) || (((struct tithek*)listbox->select->handle)->flag == 37))
2006                                {
2007                                        if(movie4k_series(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title) == 0)
2008                                        {
2009                                                oaktpage = listbox->aktpage;
2010                                                oaktline = listbox->aktline;
2011                                                ogridcol = listbox->gridcol;
2012                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
2013                                                char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0);
2014                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
2015                                                screentithekplay(tmpstr, tmpstr2, 0);
2016                                                free(tmpstr); tmpstr = NULL;
2017                                                free(tmpstr2); tmpstr2 = NULL;
2018                       
2019                                                pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 0);
2020                                                if(pagecount == 0 || tithekexit == 1) break;
2021
2022                                                listbox->aktpage = oaktpage;
2023                                                listbox->aktline = oaktline;
2024                                                listbox->gridcol = ogridcol;
2025                                                addscreenrc(grid, listbox);
2026                                        }
2027                                }
2028                                else if((((struct tithek*)listbox->select->handle)->flag == 39))
2029                                {
2030                                        if(movie4k_series_listed(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title) == 0)
2031                                        {
2032                                                oaktpage = listbox->aktpage;
2033                                                oaktline = listbox->aktline;
2034                                                ogridcol = listbox->gridcol;
2035                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
2036                                                char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0);
2037                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
2038                                                screentithekplay(tmpstr, tmpstr2, 0);
2039                                                free(tmpstr); tmpstr = NULL;
2040                                                free(tmpstr2); tmpstr2 = NULL;
2041                       
2042                                                pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 0);
2043                                                if(pagecount == 0 || tithekexit == 1) break;
2044
2045                                                listbox->aktpage = oaktpage;
2046                                                listbox->aktline = oaktline;
2047                                                listbox->gridcol = ogridcol;
2048                                                addscreenrc(grid, listbox);
2049                                        }
2050                                }
2051                                else if((((struct tithek*)listbox->select->handle)->flag == 40))
2052                                {
2053                                        if(movie4k_hoster_series(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title) == 0)
2054                                        {
2055                                                oaktpage = listbox->aktpage;
2056                                                oaktline = listbox->aktline;
2057                                                ogridcol = listbox->gridcol;
2058                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
2059                                                char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0);
2060                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
2061                                                screentithekplay(tmpstr, tmpstr2, 0);
2062                                                free(tmpstr); tmpstr = NULL;
2063                                                free(tmpstr2); tmpstr2 = NULL;
2064                       
2065                                                pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 0);
2066                                                if(pagecount == 0 || tithekexit == 1) break;
2067
2068                                                listbox->aktpage = oaktpage;
2069                                                listbox->aktline = oaktline;
2070                                                listbox->gridcol = ogridcol;
2071                                                addscreenrc(grid, listbox);
2072                                        }
2073                                }
2074                                else if((((struct tithek*)listbox->select->handle)->flag == 66))
2075                                {
2076                                        textbox(_("Message"), _("The hoster is not yet supported for the time !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 5, 0);
2077                                        continue;
2078                                }       
2079                                else if((((struct tithek*)listbox->select->handle)->flag == 3))
2080                                {
2081                                        int pincheck = 0;
2082                                        if(((struct tithek*)listbox->select->handle)->flag == 1000)
2083                                                pincheck = screenpincheck(0, NULL);
2084                                        if(pincheck == 0)
2085                                        {
2086                                                oaktpage = listbox->aktpage;
2087                                                oaktline = listbox->aktline;
2088                                                ogridcol = listbox->gridcol;
2089                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
2090                                                char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0);                                     
2091                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
2092                                                screentithekplay(tmpstr, tmpstr2, 3);
2093                                                free(tmpstr); tmpstr = NULL;
2094                                                free(tmpstr2); tmpstr2 = NULL; 
2095
2096                                                pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 0);
2097                                                if(pagecount == 0 || tithekexit == 1) break;
2098
2099                                                listbox->aktpage = oaktpage;
2100                                                listbox->aktline = oaktline;
2101                                                listbox->gridcol = ogridcol;
2102                                                addscreenrc(grid, listbox);
2103                                        }
2104                                }
2105                                else
2106                                {
2107                                        int pincheck = 0;
2108                                        if(((struct tithek*)listbox->select->handle)->flag == 1000)
2109                                                pincheck = screenpincheck(0, NULL);
2110                                        if(pincheck == 0)
2111                                        {
2112                                                oaktpage = listbox->aktpage;
2113                                                oaktline = listbox->aktline;
2114                                                ogridcol = listbox->gridcol;
2115                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
2116                                                char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0);                                     
2117                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
2118                                                screentithekplay(tmpstr, tmpstr2, 0);
2119                                                free(tmpstr); tmpstr = NULL;
2120                                                free(tmpstr2); tmpstr2 = NULL; 
2121
2122                                                pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 0);
2123                                                if(pagecount == 0 || tithekexit == 1) break;
2124
2125                                                listbox->aktpage = oaktpage;
2126                                                listbox->aktline = oaktline;
2127                                                listbox->gridcol = ogridcol;
2128                                                addscreenrc(grid, listbox);
2129                                        }
2130                                }
2131                                drawscreen(grid, 0, 0);
2132                        }                       
2133                }
2134                else if(rcret == getrcconfigint("rcyellow", NULL) && ostrcmp(title, "TiThek - Favoriten") == 0)
2135                {
2136                        if(listbox->select != NULL && listbox->select->handle != NULL)
2137                        {
2138                                if(textbox(_("Message"), _("Remove this Favorite ?"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 5, 0) == 1)
2139                                {
2140                                        removefav(((struct tithek*)listbox->select->handle)->title, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->pic, ((struct tithek*)listbox->select->handle)->localname, ((struct tithek*)listbox->select->handle)->menutitle, ((struct tithek*)listbox->select->handle)->flag);             
2141                                        pagecount = createtithekplay(titheklink, grid, listbox, countlabel, 0);
2142                                        if(pagecount == 0) return;
2143                                               
2144                                        drawscreen(grid, 0, 0);
2145                                }
2146                        }
2147                }
2148                else if(rcret == getrcconfigint("rcgreen", NULL) && ostrcmp(title, "TiThek - Favoriten") != 0)
2149                {
2150                        if(listbox->select != NULL && listbox->select->handle != NULL)
2151                        {
2152                                if(textbox(_("Message"), _("Add this link as Favorite ?"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 5, 0) == 1)
2153                                {
2154                                        addfav(((struct tithek*)listbox->select->handle)->title, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->pic, ((struct tithek*)listbox->select->handle)->localname, ((struct tithek*)listbox->select->handle)->menutitle, ((struct tithek*)listbox->select->handle)->flag);         
2155                                }
2156                        }
2157                }
2158        }
2159
2160        delmarkedscreennodes(grid, 1);
2161        delownerrc(grid);
2162        clearscreen(grid);
2163
2164        if(first == 1)
2165        {
2166                freetithek();
2167                delallfiles("/tmp/tithek", ".list");
2168                if(status.mcaktiv == 0)
2169                        servicecheckret(servicestart(status.lastservice->channel, NULL, NULL, 0), 0);
2170        }
2171}
2172
2173#endif
Note: See TracBrowser for help on using the repository browser.