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

Last change on this file since 22674 was 22674, checked in by nit, 10 years ago

[titan] testfix pagecount

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